mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-28 01:20:55 +01:00
Renamed ColorEdit/ColorPicker's ImGuiColorEditFlags_RGB/_HSV/_HEX flags to respectively ImGuiColorEditFlags_DisplayRGB/_DisplayHSV/_DisplayHex. This is anticipation of adding new flags to ColorEdit/ColorPicker functions which would make those ambiguous. (#2384) [@haldean]
This commit is contained in:
parent
8a2f6866a6
commit
6de09a5e48
@ -33,6 +33,12 @@ HOW TO UPDATE?
|
||||
VERSION 1.69 (In Progress)
|
||||
-----------------------------------------------------------------------
|
||||
|
||||
Breaking Changes:
|
||||
|
||||
- Renamed ColorEdit/ColorPicker's ImGuiColorEditFlags_RGB/_HSV/_HEX flags to respectively
|
||||
ImGuiColorEditFlags_DisplayRGB/_DisplayHSV/_DisplayHex. This is anticipation of adding new
|
||||
flags to ColorEdit/ColorPicker functions which would make those ambiguous. (#2384) [@haldean]
|
||||
|
||||
Other Changes:
|
||||
|
||||
- Nav: Fixed a tap on AltGR (e.g. German keyboard) from navigation to the menu layer.
|
||||
|
@ -364,6 +364,7 @@ CODE
|
||||
When you are not sure about a old symbol or function name, try using the Search/Find function of your IDE to look for comments or references in all imgui files.
|
||||
You can read releases logs https://github.com/ocornut/imgui/releases for more details.
|
||||
|
||||
- 2019/02/26 (1.69) - renamed ImGuiColorEditFlags_RGB/ImGuiColorEditFlags_HSV/ImGuiColorEditFlags_HEX to ImGuiColorEditFlags_DisplayRGB/ImGuiColorEditFlags_DisplayHSV/ImGuiColorEditFlags_DisplayHex. Kept redirection enums (will obsolete).
|
||||
- 2019/02/14 (1.68) - made it illegal/assert when io.DisplayTime == 0.0f (with an exception for the first frame). If for some reason your time step calculation gives you a zero value, replace it with a dummy small value!
|
||||
- 2019/02/01 (1.68) - removed io.DisplayVisibleMin/DisplayVisibleMax (which were marked obsolete and removed from viewport/docking branch already).
|
||||
- 2019/01/06 (1.67) - renamed io.InputCharacters[], marked internal as was always intended. Please don't access directly, and use AddInputCharacter() instead!
|
||||
|
24
imgui.h
24
imgui.h
@ -1095,7 +1095,7 @@ enum ImGuiStyleVar_
|
||||
enum ImGuiColorEditFlags_
|
||||
{
|
||||
ImGuiColorEditFlags_None = 0,
|
||||
ImGuiColorEditFlags_NoAlpha = 1 << 1, // // ColorEdit, ColorPicker, ColorButton: ignore Alpha component (read 3 components from the input pointer).
|
||||
ImGuiColorEditFlags_NoAlpha = 1 << 1, // // ColorEdit, ColorPicker, ColorButton: ignore Alpha component (will only read 3 components from the input pointer).
|
||||
ImGuiColorEditFlags_NoPicker = 1 << 2, // // ColorEdit: disable picker when clicking on colored square.
|
||||
ImGuiColorEditFlags_NoOptions = 1 << 3, // // ColorEdit: disable toggling options menu when right-clicking on inputs/small preview.
|
||||
ImGuiColorEditFlags_NoSmallPreview = 1 << 4, // // ColorEdit, ColorPicker: disable colored square preview next to the inputs. (e.g. to show only the inputs)
|
||||
@ -1105,28 +1105,30 @@ enum ImGuiColorEditFlags_
|
||||
ImGuiColorEditFlags_NoSidePreview = 1 << 8, // // ColorPicker: disable bigger color preview on right side of the picker, use small colored square preview instead.
|
||||
ImGuiColorEditFlags_NoDragDrop = 1 << 9, // // ColorEdit: disable drag and drop target. ColorButton: disable drag and drop source.
|
||||
|
||||
// User Options (right-click on widget to change some of them). You can set application defaults using SetColorEditOptions(). The idea is that you probably don't want to override them in most of your calls, let the user choose and/or call SetColorEditOptions() during startup.
|
||||
// User Options (right-click on widget to change some of them). You can set application defaults using SetColorEditOptions().
|
||||
// The intent is that you probably don't want to override them in most of your calls, let the user choose via the option menu and/or call SetColorEditOptions() during startup.
|
||||
ImGuiColorEditFlags_AlphaBar = 1 << 16, // // ColorEdit, ColorPicker: show vertical alpha bar/gradient in picker.
|
||||
ImGuiColorEditFlags_AlphaPreview = 1 << 17, // // ColorEdit, ColorPicker, ColorButton: display preview as a transparent color over a checkerboard, instead of opaque.
|
||||
ImGuiColorEditFlags_AlphaPreviewHalf= 1 << 18, // // ColorEdit, ColorPicker, ColorButton: display half opaque / half checkerboard, instead of opaque.
|
||||
ImGuiColorEditFlags_HDR = 1 << 19, // // (WIP) ColorEdit: Currently only disable 0.0f..1.0f limits in RGBA edition (note: you probably want to use ImGuiColorEditFlags_Float flag as well).
|
||||
ImGuiColorEditFlags_ShowRGB = 1 << 20, // [Show] // ColorEdit: choose one among RGB/HSV/HEX. ColorPicker: choose any combination using RGB/HSV/HEX.
|
||||
ImGuiColorEditFlags_ShowHSV = 1 << 21, // [Show] // "
|
||||
ImGuiColorEditFlags_ShowHEX = 1 << 22, // [Show] // "
|
||||
ImGuiColorEditFlags_DisplayRGB = 1 << 20, // [Display] // ColorEdit: override _display_ type among RGB/HSV/Hex. ColorPicker: select any combination using one or more of RGB/HSV/Hex.
|
||||
ImGuiColorEditFlags_DisplayHSV = 1 << 21, // [Display] // "
|
||||
ImGuiColorEditFlags_DisplayHex = 1 << 22, // [Display] // "
|
||||
ImGuiColorEditFlags_Uint8 = 1 << 23, // [DataType] // ColorEdit, ColorPicker, ColorButton: _display_ values formatted as 0..255.
|
||||
ImGuiColorEditFlags_Float = 1 << 24, // [DataType] // ColorEdit, ColorPicker, ColorButton: _display_ values formatted as 0.0f..1.0f floats instead of 0..255 integers. No round-trip of value via integers.
|
||||
ImGuiColorEditFlags_PickerHueBar = 1 << 25, // [PickerMode] // ColorPicker: bar for Hue, rectangle for Sat/Value.
|
||||
ImGuiColorEditFlags_PickerHueWheel = 1 << 26, // [PickerMode] // ColorPicker: wheel for Hue, triangle for Sat/Value.
|
||||
// Obsolete names (will be removed)
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
ImGuiColorEditFlags_RGB = ImGuiColorEditFlags_ShowRGB, ImGuiColorEditFlags_HSV = ImGuiColorEditFlags_ShowHSV, ImGuiColorEditFlags_HEX = ImGuiColorEditFlags_ShowHEX,
|
||||
#endif
|
||||
|
||||
// [Internal] Masks
|
||||
ImGuiColorEditFlags__ShowMask = ImGuiColorEditFlags_ShowRGB|ImGuiColorEditFlags_ShowHSV|ImGuiColorEditFlags_ShowHEX,
|
||||
ImGuiColorEditFlags__DisplayMask = ImGuiColorEditFlags_DisplayRGB|ImGuiColorEditFlags_DisplayHSV|ImGuiColorEditFlags_DisplayHex,
|
||||
ImGuiColorEditFlags__DataTypeMask = ImGuiColorEditFlags_Uint8|ImGuiColorEditFlags_Float,
|
||||
ImGuiColorEditFlags__PickerMask = ImGuiColorEditFlags_PickerHueWheel|ImGuiColorEditFlags_PickerHueBar,
|
||||
ImGuiColorEditFlags__OptionsDefault = ImGuiColorEditFlags_Uint8|ImGuiColorEditFlags_ShowRGB|ImGuiColorEditFlags_PickerHueBar // Change application default using SetColorEditOptions()
|
||||
ImGuiColorEditFlags__OptionsDefault = ImGuiColorEditFlags_Uint8|ImGuiColorEditFlags_DisplayRGB|ImGuiColorEditFlags_PickerHueBar // Change application default using SetColorEditOptions()
|
||||
|
||||
// Obsolete names (will be removed)
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
, ImGuiColorEditFlags_RGB = ImGuiColorEditFlags_DisplayRGB, ImGuiColorEditFlags_HSV = ImGuiColorEditFlags_DisplayHSV, ImGuiColorEditFlags_HEX = ImGuiColorEditFlags_DisplayHex
|
||||
#endif
|
||||
};
|
||||
|
||||
// Enumeration for GetMouseCursor()
|
||||
|
@ -1045,7 +1045,7 @@ static void ShowDemoWindowWidgets()
|
||||
ImGui::ColorEdit3("MyColor##1", (float*)&color, misc_flags);
|
||||
|
||||
ImGui::Text("Color widget HSV with Alpha:");
|
||||
ImGui::ColorEdit4("MyColor##2", (float*)&color, ImGuiColorEditFlags_ShowHSV | misc_flags);
|
||||
ImGui::ColorEdit4("MyColor##2", (float*)&color, ImGuiColorEditFlags_DisplayHSV | misc_flags);
|
||||
|
||||
ImGui::Text("Color widget with Float Display:");
|
||||
ImGui::ColorEdit4("MyColor##2f", (float*)&color, ImGuiColorEditFlags_Float | misc_flags);
|
||||
@ -1127,7 +1127,7 @@ static void ShowDemoWindowWidgets()
|
||||
static bool side_preview = true;
|
||||
static bool ref_color = false;
|
||||
static ImVec4 ref_color_v(1.0f,0.0f,1.0f,0.5f);
|
||||
static int show_mode = 2;
|
||||
static int display_mode = 0;
|
||||
static int picker_mode = 0;
|
||||
ImGui::Checkbox("With Alpha", &alpha);
|
||||
ImGui::Checkbox("With Alpha Bar", &alpha_bar);
|
||||
@ -1142,25 +1142,26 @@ static void ShowDemoWindowWidgets()
|
||||
ImGui::ColorEdit4("##RefColor", &ref_color_v.x, ImGuiColorEditFlags_NoInputs | misc_flags);
|
||||
}
|
||||
}
|
||||
ImGui::Combo("Show Mode", &show_mode, "All\0None\0Show RGB\0Show HSV\0Show HEX\0");
|
||||
ImGui::Combo("Display Mode", &display_mode, "Auto/Current\0None\0RGB Only\0HSV Only\0Hex Only\0");
|
||||
ImGui::SameLine(); ShowHelpMarker("ColorEdit defaults to displaying RGB inputs if you don't specify a display mode, but the user can change it with a right-click.\n\nColorPicker defaults to displaying RGB+HSV+Hex if you don't specify a display mode.\n\nYou can change the defaults using SetColorEditOptions().");
|
||||
ImGui::Combo("Picker Mode", &picker_mode, "Auto/Current\0Hue bar + SV rect\0Hue wheel + SV triangle\0");
|
||||
ImGui::SameLine(); ShowHelpMarker("User can right-click the picker to change mode.");
|
||||
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;
|
||||
if (picker_mode == 1) flags |= ImGuiColorEditFlags_PickerHueBar;
|
||||
if (picker_mode == 2) flags |= ImGuiColorEditFlags_PickerHueWheel;
|
||||
if (show_mode == 1) flags |= ImGuiColorEditFlags_NoInputs;
|
||||
if (show_mode == 2) flags |= ImGuiColorEditFlags_ShowRGB;
|
||||
if (show_mode == 3) flags |= ImGuiColorEditFlags_ShowHSV;
|
||||
if (show_mode == 4) flags |= ImGuiColorEditFlags_ShowHEX;
|
||||
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;
|
||||
if (picker_mode == 1) flags |= ImGuiColorEditFlags_PickerHueBar;
|
||||
if (picker_mode == 2) flags |= ImGuiColorEditFlags_PickerHueWheel;
|
||||
if (display_mode == 1) flags |= ImGuiColorEditFlags_NoInputs; // Disable all RGB/HSV/Hex displays
|
||||
if (display_mode == 2) flags |= ImGuiColorEditFlags_DisplayRGB; // Override display mode
|
||||
if (display_mode == 3) flags |= ImGuiColorEditFlags_DisplayHSV;
|
||||
if (display_mode == 4) flags |= ImGuiColorEditFlags_DisplayHex;
|
||||
ImGui::ColorPicker4("MyColor##4", (float*)&color, flags, ref_color ? &ref_color_v.x : NULL);
|
||||
|
||||
ImGui::Text("Programmatically set defaults:");
|
||||
ImGui::SameLine(); ShowHelpMarker("SetColorEditOptions() is designed to allow you to set boot-time default.\nWe don't have Push/Pop functions because you can force options on a per-widget basis if needed, and the user can change non-forced ones with the options menu.\nWe don't have a getter to avoid encouraging you to persistently save values that aren't forward-compatible.");
|
||||
if (ImGui::Button("Default: Uint8 + HSV + Hue Bar"))
|
||||
ImGui::SetColorEditOptions(ImGuiColorEditFlags_Uint8 | ImGuiColorEditFlags_ShowHSV | ImGuiColorEditFlags_PickerHueBar);
|
||||
ImGui::SetColorEditOptions(ImGuiColorEditFlags_Uint8 | ImGuiColorEditFlags_DisplayHSV | ImGuiColorEditFlags_PickerHueBar);
|
||||
if (ImGui::Button("Default: Float + HDR + Hue Wheel"))
|
||||
ImGui::SetColorEditOptions(ImGuiColorEditFlags_Float | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_PickerHueWheel);
|
||||
|
||||
|
@ -3898,20 +3898,20 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
||||
// If we're not showing any slider there's no point in doing any HSV conversions
|
||||
const ImGuiColorEditFlags flags_untouched = flags;
|
||||
if (flags & ImGuiColorEditFlags_NoInputs)
|
||||
flags = (flags & (~ImGuiColorEditFlags__ShowMask)) | ImGuiColorEditFlags_ShowRGB | ImGuiColorEditFlags_NoOptions;
|
||||
flags = (flags & (~ImGuiColorEditFlags__DisplayMask)) | ImGuiColorEditFlags_DisplayRGB | ImGuiColorEditFlags_NoOptions;
|
||||
|
||||
// Context menu: display and modify options (before defaults are applied)
|
||||
if (!(flags & ImGuiColorEditFlags_NoOptions))
|
||||
ColorEditOptionsPopup(col, flags);
|
||||
|
||||
// Read stored options
|
||||
if (!(flags & ImGuiColorEditFlags__ShowMask))
|
||||
flags |= (g.ColorEditOptions & ImGuiColorEditFlags__ShowMask);
|
||||
if (!(flags & ImGuiColorEditFlags__DisplayMask))
|
||||
flags |= (g.ColorEditOptions & ImGuiColorEditFlags__DisplayMask);
|
||||
if (!(flags & ImGuiColorEditFlags__DataTypeMask))
|
||||
flags |= (g.ColorEditOptions & ImGuiColorEditFlags__DataTypeMask);
|
||||
if (!(flags & ImGuiColorEditFlags__PickerMask))
|
||||
flags |= (g.ColorEditOptions & ImGuiColorEditFlags__PickerMask);
|
||||
flags |= (g.ColorEditOptions & ~(ImGuiColorEditFlags__ShowMask | ImGuiColorEditFlags__DataTypeMask | ImGuiColorEditFlags__PickerMask));
|
||||
flags |= (g.ColorEditOptions & ~(ImGuiColorEditFlags__DisplayMask | ImGuiColorEditFlags__DataTypeMask | ImGuiColorEditFlags__PickerMask));
|
||||
|
||||
const bool alpha = (flags & ImGuiColorEditFlags_NoAlpha) == 0;
|
||||
const bool hdr = (flags & ImGuiColorEditFlags_HDR) != 0;
|
||||
@ -3919,14 +3919,14 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
||||
|
||||
// Convert to the formats we need
|
||||
float f[4] = { col[0], col[1], col[2], alpha ? col[3] : 1.0f };
|
||||
if (flags & ImGuiColorEditFlags_ShowHSV)
|
||||
if (flags & ImGuiColorEditFlags_DisplayHSV)
|
||||
ColorConvertRGBtoHSV(f[0], f[1], f[2], f[0], f[1], f[2]);
|
||||
int i[4] = { IM_F32_TO_INT8_UNBOUND(f[0]), IM_F32_TO_INT8_UNBOUND(f[1]), IM_F32_TO_INT8_UNBOUND(f[2]), IM_F32_TO_INT8_UNBOUND(f[3]) };
|
||||
|
||||
bool value_changed = false;
|
||||
bool value_changed_as_float = false;
|
||||
|
||||
if ((flags & (ImGuiColorEditFlags_ShowRGB | ImGuiColorEditFlags_ShowHSV)) != 0 && (flags & ImGuiColorEditFlags_NoInputs) == 0)
|
||||
if ((flags & (ImGuiColorEditFlags_DisplayRGB | ImGuiColorEditFlags_DisplayHSV)) != 0 && (flags & ImGuiColorEditFlags_NoInputs) == 0)
|
||||
{
|
||||
// RGB/HSV 0..255 Sliders
|
||||
const float w_item_one = ImMax(1.0f, (float)(int)((w_items_all - (style.ItemInnerSpacing.x) * (components-1)) / (float)components));
|
||||
@ -3946,7 +3946,7 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
||||
{ "R:%0.3f", "G:%0.3f", "B:%0.3f", "A:%0.3f" }, // Long display for RGBA
|
||||
{ "H:%0.3f", "S:%0.3f", "V:%0.3f", "A:%0.3f" } // Long display for HSVA
|
||||
};
|
||||
const int fmt_idx = hide_prefix ? 0 : (flags & ImGuiColorEditFlags_ShowHSV) ? 2 : 1;
|
||||
const int fmt_idx = hide_prefix ? 0 : (flags & ImGuiColorEditFlags_DisplayHSV) ? 2 : 1;
|
||||
|
||||
PushItemWidth(w_item_one);
|
||||
for (int n = 0; n < components; n++)
|
||||
@ -3970,7 +3970,7 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
||||
PopItemWidth();
|
||||
PopItemWidth();
|
||||
}
|
||||
else if ((flags & ImGuiColorEditFlags_ShowHEX) != 0 && (flags & ImGuiColorEditFlags_NoInputs) == 0)
|
||||
else if ((flags & ImGuiColorEditFlags_DisplayHex) != 0 && (flags & ImGuiColorEditFlags_NoInputs) == 0)
|
||||
{
|
||||
// RGB Hexadecimal Input
|
||||
char buf[64];
|
||||
@ -4025,7 +4025,7 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
||||
Spacing();
|
||||
}
|
||||
ImGuiColorEditFlags picker_flags_to_forward = ImGuiColorEditFlags__DataTypeMask | ImGuiColorEditFlags__PickerMask | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_AlphaBar;
|
||||
ImGuiColorEditFlags picker_flags = (flags_untouched & picker_flags_to_forward) | ImGuiColorEditFlags__ShowMask | ImGuiColorEditFlags_NoLabel | ImGuiColorEditFlags_AlphaPreviewHalf;
|
||||
ImGuiColorEditFlags picker_flags = (flags_untouched & picker_flags_to_forward) | ImGuiColorEditFlags__DisplayMask | ImGuiColorEditFlags_NoLabel | ImGuiColorEditFlags_AlphaPreviewHalf;
|
||||
PushItemWidth(square_sz * 12.0f); // Use 256 + bar sizes?
|
||||
value_changed |= ColorPicker4("##picker", col, picker_flags, &g.ColorPickerRef.x);
|
||||
PopItemWidth();
|
||||
@ -4045,7 +4045,7 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
||||
if (!value_changed_as_float)
|
||||
for (int n = 0; n < 4; n++)
|
||||
f[n] = i[n] / 255.0f;
|
||||
if (flags & ImGuiColorEditFlags_ShowHSV)
|
||||
if (flags & ImGuiColorEditFlags_DisplayHSV)
|
||||
ColorConvertHSVtoRGB(f[0], f[1], f[2], f[0], f[1], f[2]);
|
||||
if (value_changed)
|
||||
{
|
||||
@ -4330,18 +4330,18 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
|
||||
PushItemWidth((alpha_bar ? bar1_pos_x : bar0_pos_x) + bars_width - picker_pos.x);
|
||||
ImGuiColorEditFlags sub_flags_to_forward = ImGuiColorEditFlags__DataTypeMask | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_NoOptions | ImGuiColorEditFlags_NoSmallPreview | ImGuiColorEditFlags_AlphaPreview | ImGuiColorEditFlags_AlphaPreviewHalf;
|
||||
ImGuiColorEditFlags sub_flags = (flags & sub_flags_to_forward) | ImGuiColorEditFlags_NoPicker;
|
||||
if (flags & ImGuiColorEditFlags_ShowRGB || (flags & ImGuiColorEditFlags__ShowMask) == 0)
|
||||
if (ColorEdit4("##rgb", col, sub_flags | ImGuiColorEditFlags_ShowRGB))
|
||||
if (flags & ImGuiColorEditFlags_DisplayRGB || (flags & ImGuiColorEditFlags__DisplayMask) == 0)
|
||||
if (ColorEdit4("##rgb", col, sub_flags | ImGuiColorEditFlags_DisplayRGB))
|
||||
{
|
||||
// FIXME: Hackily differenciating using the DragInt (ActiveId != 0 && !ActiveIdAllowOverlap) vs. using the InputText or DropTarget.
|
||||
// For the later we don't want to run the hue-wrap canceling code. If you are well versed in HSV picker please provide your input! (See #2050)
|
||||
value_changed_fix_hue_wrap = (g.ActiveId != 0 && !g.ActiveIdAllowOverlap);
|
||||
value_changed = true;
|
||||
}
|
||||
if (flags & ImGuiColorEditFlags_ShowHSV || (flags & ImGuiColorEditFlags__ShowMask) == 0)
|
||||
value_changed |= ColorEdit4("##hsv", col, sub_flags | ImGuiColorEditFlags_ShowHSV);
|
||||
if (flags & ImGuiColorEditFlags_ShowHEX || (flags & ImGuiColorEditFlags__ShowMask) == 0)
|
||||
value_changed |= ColorEdit4("##hex", col, sub_flags | ImGuiColorEditFlags_ShowHEX);
|
||||
if (flags & ImGuiColorEditFlags_DisplayHSV || (flags & ImGuiColorEditFlags__DisplayMask) == 0)
|
||||
value_changed |= ColorEdit4("##hsv", col, sub_flags | ImGuiColorEditFlags_DisplayHSV);
|
||||
if (flags & ImGuiColorEditFlags_DisplayHex || (flags & ImGuiColorEditFlags__DisplayMask) == 0)
|
||||
value_changed |= ColorEdit4("##hex", col, sub_flags | ImGuiColorEditFlags_DisplayHex);
|
||||
PopItemWidth();
|
||||
}
|
||||
|
||||
@ -4536,16 +4536,17 @@ bool ImGui::ColorButton(const char* desc_id, const ImVec4& col, ImGuiColorEditFl
|
||||
return pressed;
|
||||
}
|
||||
|
||||
// Initialize/override default color options
|
||||
void ImGui::SetColorEditOptions(ImGuiColorEditFlags flags)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
if ((flags & ImGuiColorEditFlags__ShowMask) == 0)
|
||||
flags |= ImGuiColorEditFlags__OptionsDefault & ImGuiColorEditFlags__ShowMask;
|
||||
if ((flags & ImGuiColorEditFlags__DisplayMask) == 0)
|
||||
flags |= ImGuiColorEditFlags__OptionsDefault & ImGuiColorEditFlags__DisplayMask;
|
||||
if ((flags & ImGuiColorEditFlags__DataTypeMask) == 0)
|
||||
flags |= ImGuiColorEditFlags__OptionsDefault & ImGuiColorEditFlags__DataTypeMask;
|
||||
if ((flags & ImGuiColorEditFlags__PickerMask) == 0)
|
||||
flags |= ImGuiColorEditFlags__OptionsDefault & ImGuiColorEditFlags__PickerMask;
|
||||
IM_ASSERT(ImIsPowerOfTwo((int)(flags & ImGuiColorEditFlags__ShowMask))); // Check only 1 option is selected
|
||||
IM_ASSERT(ImIsPowerOfTwo((int)(flags & ImGuiColorEditFlags__DisplayMask))); // Check only 1 option is selected
|
||||
IM_ASSERT(ImIsPowerOfTwo((int)(flags & ImGuiColorEditFlags__DataTypeMask))); // Check only 1 option is selected
|
||||
IM_ASSERT(ImIsPowerOfTwo((int)(flags & ImGuiColorEditFlags__PickerMask))); // Check only 1 option is selected
|
||||
g.ColorEditOptions = flags;
|
||||
@ -4578,7 +4579,7 @@ void ImGui::ColorTooltip(const char* text, const float* col, ImGuiColorEditFlags
|
||||
|
||||
void ImGui::ColorEditOptionsPopup(const float* col, ImGuiColorEditFlags flags)
|
||||
{
|
||||
bool allow_opt_inputs = !(flags & ImGuiColorEditFlags__ShowMask);
|
||||
bool allow_opt_inputs = !(flags & ImGuiColorEditFlags__DisplayMask);
|
||||
bool allow_opt_datatype = !(flags & ImGuiColorEditFlags__DataTypeMask);
|
||||
if ((!allow_opt_inputs && !allow_opt_datatype) || !BeginPopup("context"))
|
||||
return;
|
||||
@ -4586,9 +4587,9 @@ void ImGui::ColorEditOptionsPopup(const float* col, ImGuiColorEditFlags flags)
|
||||
ImGuiColorEditFlags opts = g.ColorEditOptions;
|
||||
if (allow_opt_inputs)
|
||||
{
|
||||
if (RadioButton("RGB", (opts & ImGuiColorEditFlags_ShowRGB) != 0)) opts = (opts & ~ImGuiColorEditFlags__ShowMask) | ImGuiColorEditFlags_ShowRGB;
|
||||
if (RadioButton("HSV", (opts & ImGuiColorEditFlags_ShowHSV) != 0)) opts = (opts & ~ImGuiColorEditFlags__ShowMask) | ImGuiColorEditFlags_ShowHSV;
|
||||
if (RadioButton("HEX", (opts & ImGuiColorEditFlags_ShowHEX) != 0)) opts = (opts & ~ImGuiColorEditFlags__ShowMask) | ImGuiColorEditFlags_ShowHEX;
|
||||
if (RadioButton("RGB", (opts & ImGuiColorEditFlags_DisplayRGB) != 0)) opts = (opts & ~ImGuiColorEditFlags__DisplayMask) | ImGuiColorEditFlags_DisplayRGB;
|
||||
if (RadioButton("HSV", (opts & ImGuiColorEditFlags_DisplayHSV) != 0)) opts = (opts & ~ImGuiColorEditFlags__DisplayMask) | ImGuiColorEditFlags_DisplayHSV;
|
||||
if (RadioButton("Hex", (opts & ImGuiColorEditFlags_DisplayHex) != 0)) opts = (opts & ~ImGuiColorEditFlags__DisplayMask) | ImGuiColorEditFlags_DisplayHex;
|
||||
}
|
||||
if (allow_opt_datatype)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user