Tech ENABLE_PREVIEW_LAYOUT - View type combo popup has now adaptive height

This commit is contained in:
enricoturri1966 2021-09-29 13:30:18 +02:00
parent c963c3c801
commit e088a9fc36
3 changed files with 6 additions and 5 deletions

View File

@ -3532,9 +3532,9 @@ void GCodeViewer::render_legend(float& legend_height)
_u8L("Temperature (°C)"), _u8L("Temperature (°C)"),
_u8L("Volumetric flow rate (mm³/s)"), _u8L("Volumetric flow rate (mm³/s)"),
_u8L("Tool"), _u8L("Tool"),
_u8L("Color Print") }, view_type); _u8L("Color Print") }, view_type, ImGuiComboFlags_HeightLargest);
ImGui::PopStyleColor(2); ImGui::PopStyleColor(2);
if (old_view_type != view_type) { if (old_view_type != view_type) {
set_view_type(static_cast<EViewType>(view_type)); set_view_type(static_cast<EViewType>(view_type));
wxGetApp().plater()->set_keep_current_preview_type(true); wxGetApp().plater()->set_keep_current_preview_type(true);

View File

@ -477,7 +477,7 @@ bool ImGuiWrapper::slider_float(const wxString& label, float* v, float v_min, fl
return this->slider_float(label_utf8.c_str(), v, v_min, v_max, format, power, clamp); return this->slider_float(label_utf8.c_str(), v, v_min, v_max, format, power, clamp);
} }
bool ImGuiWrapper::combo(const wxString& label, const std::vector<std::string>& options, int& selection) bool ImGuiWrapper::combo(const wxString& label, const std::vector<std::string>& options, int& selection, ImGuiComboFlags flags)
{ {
// this is to force the label to the left of the widget: // this is to force the label to the left of the widget:
#if ENABLE_PREVIEW_LAYOUT #if ENABLE_PREVIEW_LAYOUT
@ -493,7 +493,7 @@ bool ImGuiWrapper::combo(const wxString& label, const std::vector<std::string>&
bool res = false; bool res = false;
const char *selection_str = selection < int(options.size()) && selection >= 0 ? options[selection].c_str() : ""; const char *selection_str = selection < int(options.size()) && selection >= 0 ? options[selection].c_str() : "";
if (ImGui::BeginCombo("", selection_str)) { if (ImGui::BeginCombo("", selection_str, flags)) {
for (int i = 0; i < (int)options.size(); i++) { for (int i = 0; i < (int)options.size(); i++) {
if (ImGui::Selectable(options[i].c_str(), i == selection)) { if (ImGui::Selectable(options[i].c_str(), i == selection)) {
selection_out = i; selection_out = i;

View File

@ -91,7 +91,8 @@ public:
bool slider_float(const std::string& label, float* v, float v_min, float v_max, const char* format = "%.3f", float power = 1.0f, bool clamp = true); bool slider_float(const std::string& label, float* v, float v_min, float v_max, const char* format = "%.3f", float power = 1.0f, bool clamp = true);
bool slider_float(const wxString& label, float* v, float v_min, float v_max, const char* format = "%.3f", float power = 1.0f, bool clamp = true); bool slider_float(const wxString& label, float* v, float v_min, float v_max, const char* format = "%.3f", float power = 1.0f, bool clamp = true);
bool combo(const wxString& label, const std::vector<std::string>& options, int& selection); // Use -1 to not mark any option as selected // Use selection = -1 to not mark any option as selected
bool combo(const wxString& label, const std::vector<std::string>& options, int& selection, ImGuiComboFlags flags = 0);
bool undo_redo_list(const ImVec2& size, const bool is_undo, bool (*items_getter)(const bool, int, const char**), int& hovered, int& selected, int& mouse_wheel); bool undo_redo_list(const ImVec2& size, const bool is_undo, bool (*items_getter)(const bool, int, const char**), int& hovered, int& selected, int& mouse_wheel);
void search_list(const ImVec2& size, bool (*items_getter)(int, const char** label, const char** tooltip), char* search_str, void search_list(const ImVec2& size, bool (*items_getter)(int, const char** label, const char** tooltip), char* search_str,
Search::OptionViewParameters& view_params, int& selected, bool& edited, int& mouse_wheel, bool is_localized); Search::OptionViewParameters& view_params, int& selected, bool& edited, int& mouse_wheel, bool is_localized);