mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-30 20:21:12 -06:00 
			
		
		
		
	
							parent
							
								
									8a29ec2204
								
							
						
					
					
						commit
						82352c1314
					
				
					 3 changed files with 26 additions and 39 deletions
				
			
		|  | @ -2286,17 +2286,20 @@ RENDER_AGAIN: | |||
|         m_imgui->text(_(L("Shift + Left (+ drag) - select point(s)"))); | ||||
|         m_imgui->text(" ");  // vertical gap
 | ||||
| 
 | ||||
|         std::vector<wxString> options = {"0.2", "0.4", "0.6", "0.8", "1.0"}; | ||||
|         std::stringstream ss; | ||||
|         ss << std::setprecision(1) << m_new_point_head_diameter; | ||||
|         wxString str = ss.str(); | ||||
|         static const std::vector<float> options = {0.2f, 0.4f, 0.6f, 0.8f, 1.0f}; | ||||
|         static const std::vector<std::string> options_str = {"0.2", "0.4", "0.6", "0.8", "1.0"}; | ||||
|         int selection = -1; | ||||
|         for (size_t i = 0; i < options.size(); i++) { | ||||
|             if (options[i] == m_new_point_head_diameter) { selection = (int)i; } | ||||
|         } | ||||
| 
 | ||||
|         bool old_combo_state = m_combo_box_open; | ||||
|         // The combo is commented out for now, until the feature is supported by backend.
 | ||||
|         // m_combo_box_open = m_imgui->combo(_(L("Head diameter")), options, str);
 | ||||
|         // m_combo_box_open = m_imgui->combo(_(L("Head diameter")), options_str, selection);
 | ||||
|         force_refresh |= (old_combo_state != m_combo_box_open); | ||||
| 
 | ||||
|         float current_number = atof(str); | ||||
|         // float current_number = atof(str);
 | ||||
|         const float current_number = selection < options.size() ? options[selection] : m_new_point_head_diameter; | ||||
|         if (old_combo_state && !m_combo_box_open) // closing the combo must always change the sizes (even if the selection did not change)
 | ||||
|             for (auto& point_and_selection : m_editing_mode_cache) | ||||
|                 if (point_and_selection.second) { | ||||
|  |  | |||
|  | @ -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) | ||||
|  |  | |||
|  | @ -60,8 +60,7 @@ public: | |||
|     void text(const char *label); | ||||
|     void text(const std::string &label); | ||||
|     void text(const wxString &label); | ||||
|     bool combo(const wxString& label, const std::vector<std::string>& options, std::string& current_selection); | ||||
|     bool combo(const wxString& label, const std::vector<wxString>& options, wxString& current_selection); | ||||
|     bool combo(const wxString& label, const std::vector<std::string>& options, int& selection);   // Use -1 to not mark any option as selected
 | ||||
| 
 | ||||
|     void disabled_begin(bool disabled); | ||||
|     void disabled_end(); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Vojtech Kral
						Vojtech Kral