|
@@ -662,25 +662,27 @@ void ImGui::ShowTestWindow(bool* p_open)
|
|
|
{
|
|
|
static ImVec4 color = ImColor(114, 144, 154, 200);
|
|
|
|
|
|
+ static bool hdr = false;
|
|
|
static bool alpha_preview = true;
|
|
|
static bool alpha_half_preview = false;
|
|
|
+ ImGui::Checkbox("With HDR", &hdr); ImGui::SameLine(); ShowHelpMarker("Currently all this does is to lift the 0..1 limits on dragging widgets.");
|
|
|
ImGui::Checkbox("With Alpha Preview", &alpha_preview);
|
|
|
ImGui::Checkbox("With Half Alpha Preview", &alpha_half_preview);
|
|
|
- int alpha_preview_flags = alpha_half_preview ? ImGuiColorEditFlags_AlphaPreviewHalf : (alpha_preview ? ImGuiColorEditFlags_AlphaPreview : 0);
|
|
|
+ int misc_flags = (hdr ? ImGuiColorEditFlags_HDR : 0) | (alpha_half_preview ? ImGuiColorEditFlags_AlphaPreviewHalf : (alpha_preview ? ImGuiColorEditFlags_AlphaPreview : 0));
|
|
|
|
|
|
ImGui::Text("Color widget:");
|
|
|
ImGui::SameLine(); ShowHelpMarker("Click on the colored square to open a color picker.\nRight-click on the colored square to show options.\nCTRL+click on individual component to input value.\n");
|
|
|
ImGui::ColorEdit3("MyColor##1", (float*)&color, ImGuiColorEditFlags_HSV);
|
|
|
|
|
|
ImGui::Text("Color widget with Alpha:");
|
|
|
- ImGui::ColorEdit4("MyColor##2", (float*)&color, alpha_preview_flags);
|
|
|
+ ImGui::ColorEdit4("MyColor##2", (float*)&color, misc_flags);
|
|
|
|
|
|
ImGui::Text("Color widget with Float Display:");
|
|
|
- ImGui::ColorEdit4("MyColor##2f", (float*)&color, ImGuiColorEditFlags_Float | alpha_preview_flags);
|
|
|
+ ImGui::ColorEdit4("MyColor##2f", (float*)&color, ImGuiColorEditFlags_Float | misc_flags);
|
|
|
|
|
|
ImGui::Text("Color button with Picker:");
|
|
|
ImGui::SameLine(); ShowHelpMarker("With the ImGuiColorEditFlags_NoInputs flag you can hide all the slider/text inputs.\nWith the ImGuiColorEditFlags_NoLabel flag you can pass a non-empty label which will only be used for the tooltip and picker popup.");
|
|
|
- ImGui::ColorEdit4("MyColor##3", (float*)&color, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel | alpha_preview_flags);
|
|
|
+ ImGui::ColorEdit4("MyColor##3", (float*)&color, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel | misc_flags);
|
|
|
|
|
|
ImGui::Text("Color button with Custom Picker Popup:");
|
|
|
static bool saved_palette_inited = false;
|
|
@@ -689,7 +691,7 @@ void ImGui::ShowTestWindow(bool* p_open)
|
|
|
if (!saved_palette_inited)
|
|
|
for (int n = 0; n < IM_ARRAYSIZE(saved_palette); n++)
|
|
|
ImGui::ColorConvertHSVtoRGB(n / 31.0f, 0.8f, 0.8f, saved_palette[n].x, saved_palette[n].y, saved_palette[n].z);
|
|
|
- bool open_popup = ImGui::ColorButton("MyColor##3b", color, alpha_preview_flags);
|
|
|
+ bool open_popup = ImGui::ColorButton("MyColor##3b", color, misc_flags);
|
|
|
ImGui::SameLine();
|
|
|
open_popup |= ImGui::Button("Palette");
|
|
|
if (open_popup)
|
|
@@ -702,7 +704,7 @@ void ImGui::ShowTestWindow(bool* p_open)
|
|
|
// FIXME: Adding a drag and drop example here would be perfect!
|
|
|
ImGui::Text("MY CUSTOM COLOR PICKER WITH AN AMAZING PALETTE!");
|
|
|
ImGui::Separator();
|
|
|
- ImGui::ColorPicker4("##picker", (float*)&color, alpha_preview_flags | ImGuiColorEditFlags_NoSidePreview | ImGuiColorEditFlags_NoSmallPreview);
|
|
|
+ ImGui::ColorPicker4("##picker", (float*)&color, misc_flags | ImGuiColorEditFlags_NoSidePreview | ImGuiColorEditFlags_NoSmallPreview);
|
|
|
ImGui::SameLine();
|
|
|
ImGui::BeginGroup();
|
|
|
ImGui::Text("Current");
|
|
@@ -726,7 +728,7 @@ void ImGui::ShowTestWindow(bool* p_open)
|
|
|
}
|
|
|
|
|
|
ImGui::Text("Color button only:");
|
|
|
- ImGui::ColorButton("MyColor##3b", *(ImVec4*)&color, alpha_preview_flags, ImVec2(80,80));
|
|
|
+ ImGui::ColorButton("MyColor##3b", *(ImVec4*)&color, misc_flags, ImVec2(80,80));
|
|
|
|
|
|
ImGui::Text("Color picker:");
|
|
|
static bool alpha = true;
|
|
@@ -745,14 +747,14 @@ void ImGui::ShowTestWindow(bool* p_open)
|
|
|
if (ref_color)
|
|
|
{
|
|
|
ImGui::SameLine();
|
|
|
- ImGui::ColorEdit4("##RefColor", &ref_color_v.x, ImGuiColorEditFlags_NoInputs | alpha_preview_flags);
|
|
|
+ ImGui::ColorEdit4("##RefColor", &ref_color_v.x, ImGuiColorEditFlags_NoInputs | misc_flags);
|
|
|
}
|
|
|
}
|
|
|
ImGui::Combo("Mode", &inputs_mode, "All Inputs\0No Inputs\0RGB Input\0HSV Input\0HEX Input\0");
|
|
|
ImGui::SameLine(); ShowHelpMarker("User can right-click the inputs and override edit mode.");
|
|
|
//ImGui::DragFloat("Width", &width, 1.0f, 1.0f, 999.0f);
|
|
|
//ImGui::PushItemWidth(width);
|
|
|
- ImGuiColorEditFlags flags = alpha_preview_flags;
|
|
|
+ ImGuiColorEditFlags flags = misc_flags;
|
|
|
if (!alpha) flags |= ImGuiColorEditFlags_NoAlpha; // This is by default if you call ColorPicker3() instead of ColorPicker4()
|
|
|
if (alpha_bar) flags |= ImGuiColorEditFlags_AlphaBar;
|
|
|
if (!side_preview) flags |= ImGuiColorEditFlags_NoSidePreview;
|