MCPcopy Create free account
hub / github.com/GPUOpen-LibrariesAndSDKs/Cauldron / ColorPickerOptionsPopup

Function ColorPickerOptionsPopup

libs/imgui/imgui.cpp:9992–10028  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9990}
9991
9992static void ColorPickerOptionsPopup(ImGuiColorEditFlags flags, const float* ref_col)
9993{
9994 bool allow_opt_picker = !(flags & ImGuiColorEditFlags__PickerMask);
9995 bool allow_opt_alpha_bar = !(flags & ImGuiColorEditFlags_NoAlpha) && !(flags & ImGuiColorEditFlags_AlphaBar);
9996 if ((!allow_opt_picker && !allow_opt_alpha_bar) || !ImGui::BeginPopup("context"))
9997 return;
9998 ImGuiContext& g = *GImGui;
9999 if (allow_opt_picker)
10000 {
10001 ImVec2 picker_size(g.FontSize * 8, ImMax(g.FontSize * 8 - (ImGui::GetFrameHeight() + g.Style.ItemInnerSpacing.x), 1.0f)); // FIXME: Picker size copied from main picker function
10002 ImGui::PushItemWidth(picker_size.x);
10003 for (int picker_type = 0; picker_type < 2; picker_type++)
10004 {
10005 // Draw small/thumbnail version of each picker type (over an invisible button for selection)
10006 if (picker_type > 0) ImGui::Separator();
10007 ImGui::PushID(picker_type);
10008 ImGuiColorEditFlags picker_flags = ImGuiColorEditFlags_NoInputs|ImGuiColorEditFlags_NoOptions|ImGuiColorEditFlags_NoLabel|ImGuiColorEditFlags_NoSidePreview|(flags & ImGuiColorEditFlags_NoAlpha);
10009 if (picker_type == 0) picker_flags |= ImGuiColorEditFlags_PickerHueBar;
10010 if (picker_type == 1) picker_flags |= ImGuiColorEditFlags_PickerHueWheel;
10011 ImVec2 backup_pos = ImGui::GetCursorScreenPos();
10012 if (ImGui::Selectable("##selectable", false, 0, picker_size)) // By default, Selectable() is closing popup
10013 g.ColorEditOptions = (g.ColorEditOptions & ~ImGuiColorEditFlags__PickerMask) | (picker_flags & ImGuiColorEditFlags__PickerMask);
10014 ImGui::SetCursorScreenPos(backup_pos);
10015 ImVec4 dummy_ref_col;
10016 memcpy(&dummy_ref_col.x, ref_col, sizeof(float) * (picker_flags & ImGuiColorEditFlags_NoAlpha ? 3 : 4));
10017 ImGui::ColorPicker4("##dummypicker", &dummy_ref_col.x, picker_flags);
10018 ImGui::PopID();
10019 }
10020 ImGui::PopItemWidth();
10021 }
10022 if (allow_opt_alpha_bar)
10023 {
10024 if (allow_opt_picker) ImGui::Separator();
10025 ImGui::CheckboxFlags("Alpha Bar", (unsigned int*)&g.ColorEditOptions, ImGuiColorEditFlags_AlphaBar);
10026 }
10027 ImGui::EndPopup();
10028}
10029
10030// Edit colors components (each component in 0.0f..1.0f range).
10031// See enum ImGuiColorEditFlags_ for available options. e.g. Only access 3 floats if ImGuiColorEditFlags_NoAlpha flag is set.

Callers 1

ColorPicker4Method · 0.85

Calls 1

ImMaxFunction · 0.85

Tested by

no test coverage detected