MCPcopy Create free account
hub / github.com/Aegel5/SimpleSwitcher / ColorPickerOptionsPopup

Method ColorPickerOptionsPopup

imgui_tiny_app/imgui/imgui_widgets.cpp:6622–6661  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6620}
6621
6622void ImGui::ColorPickerOptionsPopup(const float* ref_col, ImGuiColorEditFlags flags)
6623{
6624 bool allow_opt_picker = !(flags & ImGuiColorEditFlags_PickerMask_);
6625 bool allow_opt_alpha_bar = !(flags & ImGuiColorEditFlags_NoAlpha) && !(flags & ImGuiColorEditFlags_AlphaBar);
6626 if ((!allow_opt_picker && !allow_opt_alpha_bar) || !BeginPopup("context"))
6627 return;
6628
6629 ImGuiContext& g = *GImGui;
6630 PushItemFlag(ImGuiItemFlags_NoMarkEdited, true);
6631 if (allow_opt_picker)
6632 {
6633 ImVec2 picker_size(g.FontSize * 8, ImMax(g.FontSize * 8 - (GetFrameHeight() + g.Style.ItemInnerSpacing.x), 1.0f)); // FIXME: Picker size copied from main picker function
6634 PushItemWidth(picker_size.x);
6635 for (int picker_type = 0; picker_type < 2; picker_type++)
6636 {
6637 // Draw small/thumbnail version of each picker type (over an invisible button for selection)
6638 if (picker_type > 0) Separator();
6639 PushID(picker_type);
6640 ImGuiColorEditFlags picker_flags = ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoOptions | ImGuiColorEditFlags_NoLabel | ImGuiColorEditFlags_NoSidePreview | (flags & ImGuiColorEditFlags_NoAlpha);
6641 if (picker_type == 0) picker_flags |= ImGuiColorEditFlags_PickerHueBar;
6642 if (picker_type == 1) picker_flags |= ImGuiColorEditFlags_PickerHueWheel;
6643 ImVec2 backup_pos = GetCursorScreenPos();
6644 if (Selectable("##selectable", false, 0, picker_size)) // By default, Selectable() is closing popup
6645 g.ColorEditOptions = (g.ColorEditOptions & ~ImGuiColorEditFlags_PickerMask_) | (picker_flags & ImGuiColorEditFlags_PickerMask_);
6646 SetCursorScreenPos(backup_pos);
6647 ImVec4 previewing_ref_col;
6648 memcpy(&previewing_ref_col, ref_col, sizeof(float) * ((picker_flags & ImGuiColorEditFlags_NoAlpha) ? 3 : 4));
6649 ColorPicker4("##previewing_picker", &previewing_ref_col.x, picker_flags);
6650 PopID();
6651 }
6652 PopItemWidth();
6653 }
6654 if (allow_opt_alpha_bar)
6655 {
6656 if (allow_opt_picker) Separator();
6657 CheckboxFlags("Alpha Bar", &g.ColorEditOptions, ImGuiColorEditFlags_AlphaBar);
6658 }
6659 PopItemFlag();
6660 EndPopup();
6661}
6662
6663//-------------------------------------------------------------------------
6664// [SECTION] Widgets: TreeNode, CollapsingHeader, etc.

Callers

nothing calls this directly

Calls 1

ImMaxFunction · 0.85

Tested by

no test coverage detected