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:
authorbubnikv <bubnikv@gmail.com>2019-03-04 14:21:00 +0300
committerbubnikv <bubnikv@gmail.com>2019-03-04 14:21:00 +0300
commitbc65827499c66b77dfc5001599a18421958eada5 (patch)
treed73fdd08ecfe38adc4f60069a82f523a52ac3ce5 /src/slic3r/GUI/ImGuiWrapper.cpp
parentdceaf73ff391748c2ea4fe36acdce012671dc459 (diff)
ImGUI wrapper text and combo methods shall accept std::string
in UTF8 format.
Diffstat (limited to 'src/slic3r/GUI/ImGuiWrapper.cpp')
-rw-r--r--src/slic3r/GUI/ImGuiWrapper.cpp31
1 files changed, 29 insertions, 2 deletions
diff --git a/src/slic3r/GUI/ImGuiWrapper.cpp b/src/slic3r/GUI/ImGuiWrapper.cpp
index 7f95b6c28..78a3f9db8 100644
--- a/src/slic3r/GUI/ImGuiWrapper.cpp
+++ b/src/slic3r/GUI/ImGuiWrapper.cpp
@@ -239,10 +239,19 @@ bool ImGuiWrapper::checkbox(const wxString &label, bool &value)
return ImGui::Checkbox(label_utf8.c_str(), &value);
}
+void ImGuiWrapper::text(const char *label)
+{
+ ImGui::Text(label, NULL);
+}
+
+void ImGuiWrapper::text(const std::string &label)
+{
+ this->text(label.c_str());
+}
+
void ImGuiWrapper::text(const wxString &label)
{
- auto label_utf8 = into_u8(label);
- ImGui::Text(label_utf8.c_str(), NULL);
+ this->text(into_u8(label).c_str());
}
@@ -267,6 +276,24 @@ bool ImGuiWrapper::combo(const wxString& label, const std::vector<wxString>& opt
return false;
}
+bool ImGuiWrapper::combo(const wxString& label, const std::vector<std::string>& options, std::string& selection)
+{
+ // this is to force the label to the left of the widget:
+ text(label);
+ ImGui::SameLine();
+
+ if (ImGui::BeginCombo("", selection.c_str())) {
+ for (const std::string& option : options) {
+ bool is_selected = (selection.empty()) ? false : (option == selection);
+ if (ImGui::Selectable(option.c_str(), is_selected))
+ selection = option;
+ }
+ ImGui::EndCombo();
+ return true;
+ }
+ return false;
+}
+
void ImGuiWrapper::disabled_begin(bool disabled)
{
wxCHECK_RET(!m_disabled, "ImGUI: Unbalanced disabled_begin() call");