Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/supermerill/SuperSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVojtech Kral <vojtech@kral.hk>2019-02-19 14:39:24 +0300
committerVojtech Kral <vojtech@kral.hk>2019-02-20 18:12:41 +0300
commit1045b43d4f1df4ddcdd01c26b0428a0d12f1ddf8 (patch)
tree3dec51a751ae7addb5bf03ea39d6402a618b07b1 /src/slic3r/GUI/ImGuiWrapper.cpp
parent5de52b7da4fa2c3f7fa17ac3414c2396f658df65 (diff)
imgui: Input fixes
Diffstat (limited to 'src/slic3r/GUI/ImGuiWrapper.cpp')
-rw-r--r--src/slic3r/GUI/ImGuiWrapper.cpp25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/slic3r/GUI/ImGuiWrapper.cpp b/src/slic3r/GUI/ImGuiWrapper.cpp
index 228d336c2..b94aa59d3 100644
--- a/src/slic3r/GUI/ImGuiWrapper.cpp
+++ b/src/slic3r/GUI/ImGuiWrapper.cpp
@@ -31,6 +31,7 @@ ImGuiWrapper::ImGuiWrapper()
, m_style_scaling(1.0)
, m_mouse_buttons(0)
, m_disabled(false)
+ , m_new_frame_open(false)
{
}
@@ -106,9 +107,10 @@ bool ImGuiWrapper::update_mouse_data(wxMouseEvent& evt)
io.MouseDown[2] = evt.MiddleDown();
unsigned buttons = (evt.LeftDown() ? 1 : 0) | (evt.RightDown() ? 2 : 0) | (evt.MiddleDown() ? 4 : 0);
- bool res = buttons != m_mouse_buttons;
m_mouse_buttons = buttons;
- return res;
+
+ new_frame();
+ return want_mouse();
}
bool ImGuiWrapper::update_key_data(wxKeyEvent &evt)
@@ -117,7 +119,10 @@ bool ImGuiWrapper::update_key_data(wxKeyEvent &evt)
if (evt.GetEventType() == wxEVT_CHAR) {
// Char event
- io.AddInputCharacter(evt.GetUnicodeKey());
+ const auto key = evt.GetUnicodeKey();
+ if (key != 0) {
+ io.AddInputCharacter(key);
+ }
} else {
// Key up/down event
int key = evt.GetKeyCode();
@@ -130,21 +135,31 @@ bool ImGuiWrapper::update_key_data(wxKeyEvent &evt)
io.KeySuper = evt.MetaDown();
}
+ // XXX: Unfortunatelly this seems broken due to some interference with wxWidgets,
+ // we have to return true always (perform re-render).
+ // new_frame();
+ // return want_keyboard() || want_text_input();
return true;
}
void ImGuiWrapper::new_frame()
{
+ if (m_new_frame_open) {
+ return;
+ }
+
if (m_font_texture == 0)
create_device_objects();
ImGui::NewFrame();
+ m_new_frame_open = true;
}
void ImGuiWrapper::render()
{
ImGui::Render();
render_draw_data(ImGui::GetDrawData());
+ m_new_frame_open = false;
}
void ImGuiWrapper::set_next_window_pos(float x, float y, int flag)
@@ -492,8 +507,8 @@ const char* ImGuiWrapper::clipboard_get(void* user_data)
wxTheClipboard->GetData(data);
if (data.GetTextLength() > 0) {
- self->clipboard_text = into_u8(data.GetText());
- res = self->clipboard_text.c_str();
+ self->m_clipboard_text = into_u8(data.GetText());
+ res = self->m_clipboard_text.c_str();
}
}