mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 08:47:52 -06:00
parent
8a29ec2204
commit
82352c1314
3 changed files with 26 additions and 39 deletions
|
@ -254,44 +254,29 @@ void ImGuiWrapper::text(const wxString &label)
|
|||
this->text(into_u8(label).c_str());
|
||||
}
|
||||
|
||||
|
||||
bool ImGuiWrapper::combo(const wxString& label, const std::vector<wxString>& options, wxString& selection)
|
||||
{
|
||||
std::string selection_u8 = into_u8(selection);
|
||||
|
||||
// this is to force the label to the left of the widget:
|
||||
text(label);
|
||||
ImGui::SameLine();
|
||||
|
||||
if (ImGui::BeginCombo("", selection_u8.c_str())) {
|
||||
for (const wxString& option : options) {
|
||||
std::string option_u8 = into_u8(option);
|
||||
bool is_selected = (selection_u8.empty()) ? false : (option_u8 == selection_u8);
|
||||
if (ImGui::Selectable(option_u8.c_str(), is_selected))
|
||||
selection = option_u8;
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ImGuiWrapper::combo(const wxString& label, const std::vector<std::string>& options, std::string& selection)
|
||||
bool ImGuiWrapper::combo(const wxString& label, const std::vector<std::string>& options, int& 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;
|
||||
|
||||
int selection_out = -1;
|
||||
bool res = false;
|
||||
|
||||
const char *selection_str = selection < options.size() ? options[selection].c_str() : "";
|
||||
if (ImGui::BeginCombo("", selection_str)) {
|
||||
for (int i = 0; i < options.size(); i++) {
|
||||
if (ImGui::Selectable(options[i].c_str(), i == selection)) {
|
||||
selection_out = i;
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::EndCombo();
|
||||
return true;
|
||||
res = true;
|
||||
}
|
||||
return false;
|
||||
|
||||
selection = selection_out;
|
||||
return res;
|
||||
}
|
||||
|
||||
void ImGuiWrapper::disabled_begin(bool disabled)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue