UI selection Workspace in Geometry View

Back to the combo box (smaller and unified with other views) but following the unified color accent.
This commit is contained in:
Bruno Herbelin
2023-03-23 22:49:35 +01:00
parent b97674a404
commit d86754b0e6
3 changed files with 69 additions and 33 deletions

View File

@@ -463,7 +463,7 @@ bool ImGuiToolkit::ButtonIconMultistate(std::vector<std::pair<int, int> > icons,
return ret;
}
bool ImGuiToolkit::ComboIcon (const char* label, int* current_item, std::vector< std::tuple<int, int, std::string> > items)
bool ImGuiToolkit::ComboIcon (const char* label, int* current_item, std::vector< std::tuple<int, int, std::string> > items, bool tooltiptext)
{
bool ret = false;
ImGuiContext& g = *GImGui;
@@ -478,22 +478,41 @@ bool ImGuiToolkit::ComboIcon (const char* label, int* current_item, std::vector<
space_buf[space_num]='\0';
char text_buf[256];
ImFormatString(text_buf, IM_ARRAYSIZE(text_buf), "%s %s", space_buf, std::get<2>( items.at(*current_item) ).c_str());
if ( ImGui::BeginCombo( label, text_buf, ImGuiComboFlags_None) ) {
for (int p = 0; p < (int) items.size(); ++p){
ImGui::PushID((void*)(intptr_t)p);
if (ImGuiToolkit::SelectableIcon( std::get<2>( items.at(p) ).c_str(),
std::get<0>( items.at(p) ),
std::get<1>( items.at(p) ),
p == *current_item) ) {
*current_item = p;
ret = true;
if (tooltiptext) {
ImFormatString(text_buf, IM_ARRAYSIZE(text_buf), "%s", space_buf);
if ( ImGui::BeginCombo( label, text_buf, ImGuiComboFlags_None) ) {
for (int p = 0; p < (int) items.size(); ++p){
ImGui::PushID((void*)(intptr_t)p);
if (ImGuiToolkit::SelectableIcon( "",
std::get<0>( items.at(p) ),
std::get<1>( items.at(p) ),
p == *current_item) ) {
*current_item = p;
ret = true;
}
if (ImGui::IsItemHovered())
ImGuiToolkit::ToolTip(std::get<2>( items.at(p) ).c_str());
ImGui::PopID();
}
ImGui::PopID();
ImGui::EndCombo();
}
}
else {
ImFormatString(text_buf, IM_ARRAYSIZE(text_buf), "%s %s", space_buf, std::get<2>( items.at(*current_item) ).c_str());
if ( ImGui::BeginCombo( label, text_buf, ImGuiComboFlags_None) ) {
for (int p = 0; p < (int) items.size(); ++p){
ImGui::PushID((void*)(intptr_t)p);
if (ImGuiToolkit::SelectableIcon( std::get<2>( items.at(p) ).c_str(),
std::get<0>( items.at(p) ),
std::get<1>( items.at(p) ),
p == *current_item) ) {
*current_item = p;
ret = true;
}
ImGui::PopID();
}
ImGui::EndCombo();
}
ImGui::EndCombo();
}
// overlay of icon on top of first item