|
|
@@ -701,49 +701,57 @@ ImGuiStyle::ImGuiStyle()
|
|
|
AntiAliasedShapes = true; // Enable anti-aliasing on filled shapes (rounded rectangles, circles, etc.)
|
|
|
CurveTessellationTol = 1.25f; // Tessellation tolerance. Decrease for highly tessellated curves (higher quality, more polygons), increase to reduce quality.
|
|
|
|
|
|
- Colors[ImGuiCol_Text] = ImVec4(0.90f, 0.90f, 0.90f, 1.00f);
|
|
|
- Colors[ImGuiCol_TextDisabled] = ImVec4(0.60f, 0.60f, 0.60f, 1.00f);
|
|
|
- Colors[ImGuiCol_WindowBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.70f);
|
|
|
- Colors[ImGuiCol_ChildWindowBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
|
|
|
- Colors[ImGuiCol_PopupBg] = ImVec4(0.05f, 0.05f, 0.10f, 0.90f);
|
|
|
- Colors[ImGuiCol_Border] = ImVec4(0.70f, 0.70f, 0.70f, 0.40f);
|
|
|
- Colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
|
|
|
- Colors[ImGuiCol_FrameBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.30f); // Background of checkbox, radio button, plot, slider, text input
|
|
|
- Colors[ImGuiCol_FrameBgHovered] = ImVec4(0.90f, 0.80f, 0.80f, 0.40f);
|
|
|
- Colors[ImGuiCol_FrameBgActive] = ImVec4(0.90f, 0.65f, 0.65f, 0.45f);
|
|
|
- Colors[ImGuiCol_TitleBg] = ImVec4(0.27f, 0.27f, 0.54f, 0.83f);
|
|
|
- Colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.40f, 0.40f, 0.80f, 0.20f);
|
|
|
- Colors[ImGuiCol_TitleBgActive] = ImVec4(0.32f, 0.32f, 0.63f, 0.87f);
|
|
|
- Colors[ImGuiCol_MenuBarBg] = ImVec4(0.40f, 0.40f, 0.55f, 0.80f);
|
|
|
- Colors[ImGuiCol_ScrollbarBg] = ImVec4(0.20f, 0.25f, 0.30f, 0.60f);
|
|
|
- Colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.40f, 0.40f, 0.80f, 0.30f);
|
|
|
- Colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.40f, 0.40f, 0.80f, 0.40f);
|
|
|
- Colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.80f, 0.50f, 0.50f, 0.40f);
|
|
|
- Colors[ImGuiCol_ComboBg] = ImVec4(0.20f, 0.20f, 0.20f, 0.99f);
|
|
|
- Colors[ImGuiCol_CheckMark] = ImVec4(0.90f, 0.90f, 0.90f, 0.50f);
|
|
|
- Colors[ImGuiCol_SliderGrab] = ImVec4(1.00f, 1.00f, 1.00f, 0.30f);
|
|
|
- Colors[ImGuiCol_SliderGrabActive] = ImVec4(0.80f, 0.50f, 0.50f, 1.00f);
|
|
|
- Colors[ImGuiCol_Button] = ImVec4(0.67f, 0.40f, 0.40f, 0.60f);
|
|
|
- Colors[ImGuiCol_ButtonHovered] = ImVec4(0.67f, 0.40f, 0.40f, 1.00f);
|
|
|
- Colors[ImGuiCol_ButtonActive] = ImVec4(0.80f, 0.50f, 0.50f, 1.00f);
|
|
|
- Colors[ImGuiCol_Header] = ImVec4(0.40f, 0.40f, 0.90f, 0.45f);
|
|
|
- Colors[ImGuiCol_HeaderHovered] = ImVec4(0.45f, 0.45f, 0.90f, 0.80f);
|
|
|
- Colors[ImGuiCol_HeaderActive] = ImVec4(0.53f, 0.53f, 0.87f, 0.80f);
|
|
|
- Colors[ImGuiCol_Separator] = ImVec4(0.50f, 0.50f, 0.50f, 1.00f);
|
|
|
- Colors[ImGuiCol_SeparatorHovered] = ImVec4(0.60f, 0.60f, 0.70f, 1.00f);
|
|
|
- Colors[ImGuiCol_SeparatorActive] = ImVec4(0.70f, 0.70f, 0.90f, 1.00f);
|
|
|
- Colors[ImGuiCol_ResizeGrip] = ImVec4(1.00f, 1.00f, 1.00f, 0.30f);
|
|
|
- Colors[ImGuiCol_ResizeGripHovered] = ImVec4(1.00f, 1.00f, 1.00f, 0.60f);
|
|
|
- Colors[ImGuiCol_ResizeGripActive] = ImVec4(1.00f, 1.00f, 1.00f, 0.90f);
|
|
|
- Colors[ImGuiCol_CloseButton] = ImVec4(0.50f, 0.50f, 0.90f, 0.50f);
|
|
|
- Colors[ImGuiCol_CloseButtonHovered] = ImVec4(0.70f, 0.70f, 0.90f, 0.60f);
|
|
|
- Colors[ImGuiCol_CloseButtonActive] = ImVec4(0.70f, 0.70f, 0.70f, 1.00f);
|
|
|
- Colors[ImGuiCol_PlotLines] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
|
|
|
- Colors[ImGuiCol_PlotLinesHovered] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
|
|
|
- Colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
|
|
|
- Colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f);
|
|
|
- Colors[ImGuiCol_TextSelectedBg] = ImVec4(0.00f, 0.00f, 1.00f, 0.35f);
|
|
|
- Colors[ImGuiCol_ModalWindowDarkening] = ImVec4(0.20f, 0.20f, 0.20f, 0.35f);
|
|
|
+ ImGui::StyleColorsClassic(this);
|
|
|
+}
|
|
|
+
|
|
|
+void ImGui::StyleColorsClassic(ImGuiStyle* dst)
|
|
|
+{
|
|
|
+ ImGuiStyle* style = dst ? dst : &ImGui::GetStyle();
|
|
|
+ ImVec4* colors = style->Colors;
|
|
|
+
|
|
|
+ colors[ImGuiCol_Text] = ImVec4(0.90f, 0.90f, 0.90f, 1.00f);
|
|
|
+ colors[ImGuiCol_TextDisabled] = ImVec4(0.60f, 0.60f, 0.60f, 1.00f);
|
|
|
+ colors[ImGuiCol_WindowBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.70f);
|
|
|
+ colors[ImGuiCol_ChildWindowBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
|
|
|
+ colors[ImGuiCol_PopupBg] = ImVec4(0.05f, 0.05f, 0.10f, 0.90f);
|
|
|
+ colors[ImGuiCol_Border] = ImVec4(0.70f, 0.70f, 0.70f, 0.40f);
|
|
|
+ colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
|
|
|
+ colors[ImGuiCol_FrameBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.30f); // Background of checkbox, radio button, plot, slider, text input
|
|
|
+ colors[ImGuiCol_FrameBgHovered] = ImVec4(0.90f, 0.80f, 0.80f, 0.40f);
|
|
|
+ colors[ImGuiCol_FrameBgActive] = ImVec4(0.90f, 0.65f, 0.65f, 0.45f);
|
|
|
+ colors[ImGuiCol_TitleBg] = ImVec4(0.27f, 0.27f, 0.54f, 0.83f);
|
|
|
+ colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.40f, 0.40f, 0.80f, 0.20f);
|
|
|
+ colors[ImGuiCol_TitleBgActive] = ImVec4(0.32f, 0.32f, 0.63f, 0.87f);
|
|
|
+ colors[ImGuiCol_MenuBarBg] = ImVec4(0.40f, 0.40f, 0.55f, 0.80f);
|
|
|
+ colors[ImGuiCol_ScrollbarBg] = ImVec4(0.20f, 0.25f, 0.30f, 0.60f);
|
|
|
+ colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.40f, 0.40f, 0.80f, 0.30f);
|
|
|
+ colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.40f, 0.40f, 0.80f, 0.40f);
|
|
|
+ colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.80f, 0.50f, 0.50f, 0.40f);
|
|
|
+ colors[ImGuiCol_ComboBg] = ImVec4(0.20f, 0.20f, 0.20f, 0.99f);
|
|
|
+ colors[ImGuiCol_CheckMark] = ImVec4(0.90f, 0.90f, 0.90f, 0.50f);
|
|
|
+ colors[ImGuiCol_SliderGrab] = ImVec4(1.00f, 1.00f, 1.00f, 0.30f);
|
|
|
+ colors[ImGuiCol_SliderGrabActive] = ImVec4(0.80f, 0.50f, 0.50f, 1.00f);
|
|
|
+ colors[ImGuiCol_Button] = ImVec4(0.67f, 0.40f, 0.40f, 0.60f);
|
|
|
+ colors[ImGuiCol_ButtonHovered] = ImVec4(0.67f, 0.40f, 0.40f, 1.00f);
|
|
|
+ colors[ImGuiCol_ButtonActive] = ImVec4(0.80f, 0.50f, 0.50f, 1.00f);
|
|
|
+ colors[ImGuiCol_Header] = ImVec4(0.40f, 0.40f, 0.90f, 0.45f);
|
|
|
+ colors[ImGuiCol_HeaderHovered] = ImVec4(0.45f, 0.45f, 0.90f, 0.80f);
|
|
|
+ colors[ImGuiCol_HeaderActive] = ImVec4(0.53f, 0.53f, 0.87f, 0.80f);
|
|
|
+ colors[ImGuiCol_Separator] = ImVec4(0.50f, 0.50f, 0.50f, 1.00f);
|
|
|
+ colors[ImGuiCol_SeparatorHovered] = ImVec4(0.60f, 0.60f, 0.70f, 1.00f);
|
|
|
+ colors[ImGuiCol_SeparatorActive] = ImVec4(0.70f, 0.70f, 0.90f, 1.00f);
|
|
|
+ colors[ImGuiCol_ResizeGrip] = ImVec4(1.00f, 1.00f, 1.00f, 0.30f);
|
|
|
+ colors[ImGuiCol_ResizeGripHovered] = ImVec4(1.00f, 1.00f, 1.00f, 0.60f);
|
|
|
+ colors[ImGuiCol_ResizeGripActive] = ImVec4(1.00f, 1.00f, 1.00f, 0.90f);
|
|
|
+ colors[ImGuiCol_CloseButton] = ImVec4(0.50f, 0.50f, 0.90f, 0.50f);
|
|
|
+ colors[ImGuiCol_CloseButtonHovered] = ImVec4(0.70f, 0.70f, 0.90f, 0.60f);
|
|
|
+ colors[ImGuiCol_CloseButtonActive] = ImVec4(0.70f, 0.70f, 0.70f, 1.00f);
|
|
|
+ colors[ImGuiCol_PlotLines] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
|
|
|
+ colors[ImGuiCol_PlotLinesHovered] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
|
|
|
+ colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
|
|
|
+ colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f);
|
|
|
+ colors[ImGuiCol_TextSelectedBg] = ImVec4(0.00f, 0.00f, 1.00f, 0.35f);
|
|
|
+ colors[ImGuiCol_ModalWindowDarkening] = ImVec4(0.20f, 0.20f, 0.20f, 0.35f);
|
|
|
}
|
|
|
|
|
|
ImGuiIO::ImGuiIO()
|
|
|
@@ -3409,7 +3417,7 @@ static ImRect GetVisibleRect()
|
|
|
}
|
|
|
|
|
|
// Not exposed publicly as BeginTooltip() because bool parameters are evil. Let's see if other needs arise first.
|
|
|
-static void BeginTooltipEx(bool override_previous_tooltip)
|
|
|
+static void BeginTooltipEx(ImGuiWindowFlags extra_flags, bool override_previous_tooltip)
|
|
|
{
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
char window_name[16];
|
|
|
@@ -3422,12 +3430,13 @@ static void BeginTooltipEx(bool override_previous_tooltip)
|
|
|
window->HiddenFrames = 1;
|
|
|
ImFormatString(window_name, IM_ARRAYSIZE(window_name), "##Tooltip%02d", ++g.TooltipOverrideCount);
|
|
|
}
|
|
|
- ImGui::Begin(window_name, NULL, ImGuiWindowFlags_Tooltip|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoSavedSettings|ImGuiWindowFlags_AlwaysAutoResize);
|
|
|
+ ImGuiWindowFlags flags = ImGuiWindowFlags_Tooltip|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoSavedSettings|ImGuiWindowFlags_AlwaysAutoResize;
|
|
|
+ ImGui::Begin(window_name, NULL, flags | extra_flags);
|
|
|
}
|
|
|
|
|
|
void ImGui::SetTooltipV(const char* fmt, va_list args)
|
|
|
{
|
|
|
- BeginTooltipEx(true);
|
|
|
+ BeginTooltipEx(0, true);
|
|
|
TextV(fmt, args);
|
|
|
EndTooltip();
|
|
|
}
|
|
|
@@ -3442,7 +3451,7 @@ void ImGui::SetTooltip(const char* fmt, ...)
|
|
|
|
|
|
void ImGui::BeginTooltip()
|
|
|
{
|
|
|
- BeginTooltipEx(false);
|
|
|
+ BeginTooltipEx(0, false);
|
|
|
}
|
|
|
|
|
|
void ImGui::EndTooltip()
|
|
|
@@ -4819,7 +4828,7 @@ struct ImGuiStyleVarInfo
|
|
|
{
|
|
|
ImGuiDataType Type;
|
|
|
ImU32 Offset;
|
|
|
- void* GetVarPtr() const { return (void*)((unsigned char*)&GImGui->Style + Offset); }
|
|
|
+ void* GetVarPtr(ImGuiStyle* style) const { return (void*)((unsigned char*)style + Offset); }
|
|
|
};
|
|
|
|
|
|
static const ImGuiStyleVarInfo GStyleVarInfo[ImGuiStyleVar_Count_] =
|
|
|
@@ -4850,8 +4859,9 @@ void ImGui::PushStyleVar(ImGuiStyleVar idx, float val)
|
|
|
const ImGuiStyleVarInfo* var_info = GetStyleVarInfo(idx);
|
|
|
if (var_info->Type == ImGuiDataType_Float)
|
|
|
{
|
|
|
- float* pvar = (float*)var_info->GetVarPtr();
|
|
|
- GImGui->StyleModifiers.push_back(ImGuiStyleMod(idx, *pvar));
|
|
|
+ ImGuiContext& g = *GImGui;
|
|
|
+ float* pvar = (float*)var_info->GetVarPtr(&g.Style);
|
|
|
+ g.StyleModifiers.push_back(ImGuiStyleMod(idx, *pvar));
|
|
|
*pvar = val;
|
|
|
return;
|
|
|
}
|
|
|
@@ -4863,8 +4873,9 @@ void ImGui::PushStyleVar(ImGuiStyleVar idx, const ImVec2& val)
|
|
|
const ImGuiStyleVarInfo* var_info = GetStyleVarInfo(idx);
|
|
|
if (var_info->Type == ImGuiDataType_Float2)
|
|
|
{
|
|
|
- ImVec2* pvar = (ImVec2*)var_info->GetVarPtr();
|
|
|
- GImGui->StyleModifiers.push_back(ImGuiStyleMod(idx, *pvar));
|
|
|
+ ImGuiContext& g = *GImGui;
|
|
|
+ ImVec2* pvar = (ImVec2*)var_info->GetVarPtr(&g.Style);
|
|
|
+ g.StyleModifiers.push_back(ImGuiStyleMod(idx, *pvar));
|
|
|
*pvar = val;
|
|
|
return;
|
|
|
}
|
|
|
@@ -4878,9 +4889,9 @@ void ImGui::PopStyleVar(int count)
|
|
|
{
|
|
|
ImGuiStyleMod& backup = g.StyleModifiers.back();
|
|
|
const ImGuiStyleVarInfo* info = GetStyleVarInfo(backup.VarIdx);
|
|
|
- if (info->Type == ImGuiDataType_Float) (*(float*)info->GetVarPtr()) = backup.BackupFloat[0];
|
|
|
- else if (info->Type == ImGuiDataType_Float2) (*(ImVec2*)info->GetVarPtr()) = ImVec2(backup.BackupFloat[0], backup.BackupFloat[1]);
|
|
|
- else if (info->Type == ImGuiDataType_Int) (*(int*)info->GetVarPtr()) = backup.BackupInt[0];
|
|
|
+ if (info->Type == ImGuiDataType_Float) (*(float*)info->GetVarPtr(&g.Style)) = backup.BackupFloat[0];
|
|
|
+ else if (info->Type == ImGuiDataType_Float2) (*(ImVec2*)info->GetVarPtr(&g.Style)) = ImVec2(backup.BackupFloat[0], backup.BackupFloat[1]);
|
|
|
+ else if (info->Type == ImGuiDataType_Int) (*(int*)info->GetVarPtr(&g.Style)) = backup.BackupInt[0];
|
|
|
g.StyleModifiers.pop_back();
|
|
|
count--;
|
|
|
}
|
|
|
@@ -4902,8 +4913,8 @@ const char* ImGui::GetStyleColorName(ImGuiCol idx)
|
|
|
case ImGuiCol_FrameBgHovered: return "FrameBgHovered";
|
|
|
case ImGuiCol_FrameBgActive: return "FrameBgActive";
|
|
|
case ImGuiCol_TitleBg: return "TitleBg";
|
|
|
- case ImGuiCol_TitleBgCollapsed: return "TitleBgCollapsed";
|
|
|
case ImGuiCol_TitleBgActive: return "TitleBgActive";
|
|
|
+ case ImGuiCol_TitleBgCollapsed: return "TitleBgCollapsed";
|
|
|
case ImGuiCol_MenuBarBg: return "MenuBarBg";
|
|
|
case ImGuiCol_ScrollbarBg: return "ScrollbarBg";
|
|
|
case ImGuiCol_ScrollbarGrab: return "ScrollbarGrab";
|
|
|
@@ -8377,6 +8388,12 @@ bool ImGui::InputTextMultiline(const char* label, char* buf, size_t buf_size, co
|
|
|
return InputTextEx(label, buf, (int)buf_size, size, flags | ImGuiInputTextFlags_Multiline, callback, user_data);
|
|
|
}
|
|
|
|
|
|
+static inline float SmallSquareSize()
|
|
|
+{
|
|
|
+ ImGuiContext& g = *GImGui;
|
|
|
+ return g.FontSize + g.Style.FramePadding.y * 2.0f;
|
|
|
+}
|
|
|
+
|
|
|
// NB: scalar_format here must be a simple "%xx" format string with no prefix/suffix (unlike the Drag/Slider functions "display_format" argument)
|
|
|
bool ImGui::InputScalarEx(const char* label, ImGuiDataType data_type, void* data_ptr, void* step_ptr, void* step_fast_ptr, const char* scalar_format, ImGuiInputTextFlags extra_flags)
|
|
|
{
|
|
|
@@ -8390,7 +8407,7 @@ bool ImGui::InputScalarEx(const char* label, ImGuiDataType data_type, void* data
|
|
|
|
|
|
BeginGroup();
|
|
|
PushID(label);
|
|
|
- const ImVec2 button_sz = ImVec2(g.FontSize, g.FontSize) + style.FramePadding*2.0f;
|
|
|
+ const ImVec2 button_sz = ImVec2(SmallSquareSize(), SmallSquareSize());
|
|
|
if (step_ptr)
|
|
|
PushItemWidth(ImMax(1.0f, CalcItemWidth() - (button_sz.x + style.ItemInnerSpacing.x)*2));
|
|
|
|
|
|
@@ -8604,14 +8621,14 @@ bool ImGui::BeginCombo(const char* label, const char* preview_value, float popup
|
|
|
if (!ItemAdd(total_bb, &id))
|
|
|
return false;
|
|
|
|
|
|
- const float arrow_size = (g.FontSize + style.FramePadding.x * 2.0f);
|
|
|
+ const float arrow_size = SmallSquareSize();
|
|
|
const bool hovered = IsHovered(frame_bb, id);
|
|
|
bool popup_open = IsPopupOpen(id);
|
|
|
|
|
|
const ImRect value_bb(frame_bb.Min, frame_bb.Max - ImVec2(arrow_size, 0.0f));
|
|
|
RenderFrame(frame_bb.Min, frame_bb.Max, GetColorU32(ImGuiCol_FrameBg), true, style.FrameRounding);
|
|
|
RenderFrame(ImVec2(frame_bb.Max.x-arrow_size, frame_bb.Min.y), frame_bb.Max, GetColorU32(popup_open || hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button), true, style.FrameRounding); // FIXME-ROUNDING
|
|
|
- RenderCollapseTriangle(ImVec2(frame_bb.Max.x-arrow_size, frame_bb.Min.y) + style.FramePadding, true);
|
|
|
+ RenderCollapseTriangle(ImVec2(frame_bb.Max.x - arrow_size + style.FramePadding.y, frame_bb.Min.y + style.FramePadding.y), true);
|
|
|
|
|
|
if (preview_value != NULL)
|
|
|
RenderTextClipped(frame_bb.Min + style.FramePadding, value_bb.Max, preview_value, NULL, NULL, ImVec2(0.0f,0.0f));
|
|
|
@@ -9121,7 +9138,7 @@ void ImGui::ColorTooltip(const char* text, const float col[4], ImGuiColorEditFla
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
|
|
|
int cr = IM_F32_TO_INT8_SAT(col[0]), cg = IM_F32_TO_INT8_SAT(col[1]), cb = IM_F32_TO_INT8_SAT(col[2]), ca = (flags & ImGuiColorEditFlags_NoAlpha) ? 255 : IM_F32_TO_INT8_SAT(col[3]);
|
|
|
- BeginTooltipEx(true);
|
|
|
+ BeginTooltipEx(0, true);
|
|
|
|
|
|
const char* text_end = text ? FindRenderedTextEnd(text, NULL) : text;
|
|
|
if (text_end > text)
|
|
|
@@ -9140,12 +9157,6 @@ void ImGui::ColorTooltip(const char* text, const float col[4], ImGuiColorEditFla
|
|
|
EndTooltip();
|
|
|
}
|
|
|
|
|
|
-static inline float ColorSquareSize()
|
|
|
-{
|
|
|
- ImGuiContext& g = *GImGui;
|
|
|
- return g.FontSize + g.Style.FramePadding.y * 2.0f;
|
|
|
-}
|
|
|
-
|
|
|
static inline ImU32 ImAlphaBlendColor(ImU32 col_a, ImU32 col_b)
|
|
|
{
|
|
|
float t = ((col_b >> IM_COL32_A_SHIFT) & 0xFF) / 255.f;
|
|
|
@@ -9217,7 +9228,7 @@ bool ImGui::ColorButton(const char* desc_id, const ImVec4& col, ImGuiColorEditFl
|
|
|
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
const ImGuiID id = window->GetID(desc_id);
|
|
|
- float default_size = ColorSquareSize();
|
|
|
+ float default_size = SmallSquareSize();
|
|
|
if (size.x == 0.0f)
|
|
|
size.x = default_size;
|
|
|
if (size.y == 0.0f)
|
|
|
@@ -9262,7 +9273,7 @@ bool ImGui::ColorEdit3(const char* label, float col[3], ImGuiColorEditFlags flag
|
|
|
return ColorEdit4(label, col, flags | ImGuiColorEditFlags_NoAlpha);
|
|
|
}
|
|
|
|
|
|
-static void ColorEditOptionsPopup(ImGuiColorEditFlags flags)
|
|
|
+static void ColorEditOptionsPopup(ImGuiColorEditFlags flags, float* col)
|
|
|
{
|
|
|
bool allow_opt_inputs = !(flags & ImGuiColorEditFlags__InputsMask);
|
|
|
bool allow_opt_datatype = !(flags & ImGuiColorEditFlags__DataTypeMask);
|
|
|
@@ -9282,6 +9293,26 @@ static void ColorEditOptionsPopup(ImGuiColorEditFlags flags)
|
|
|
if (ImGui::RadioButton("0..255", (opts & ImGuiColorEditFlags_Uint8) ? 1 : 0)) opts = (opts & ~ImGuiColorEditFlags__DataTypeMask) | ImGuiColorEditFlags_Uint8;
|
|
|
if (ImGui::RadioButton("0.00..1.00", (opts & ImGuiColorEditFlags_Float) ? 1 : 0)) opts = (opts & ~ImGuiColorEditFlags__DataTypeMask) | ImGuiColorEditFlags_Float;
|
|
|
}
|
|
|
+
|
|
|
+ if (allow_opt_inputs || allow_opt_datatype) ImGui::Separator();
|
|
|
+ if (ImGui::Button("Copy as..", ImVec2(-1,0)))
|
|
|
+ ImGui::OpenPopup("Copy");
|
|
|
+ if (ImGui::BeginPopup("Copy"))
|
|
|
+ {
|
|
|
+ int cr = IM_F32_TO_INT8_SAT(col[0]), cg = IM_F32_TO_INT8_SAT(col[1]), cb = IM_F32_TO_INT8_SAT(col[2]), ca = (flags & ImGuiColorEditFlags_NoAlpha) ? 255 : IM_F32_TO_INT8_SAT(col[3]);
|
|
|
+ char buf[64];
|
|
|
+ sprintf(buf, "(%.3ff, %.3ff, %.3ff, %.3ff)", col[0], col[1], col[2], (flags & ImGuiColorEditFlags_NoAlpha) ? 1.0f : col[3]);
|
|
|
+ if (ImGui::Selectable(buf))
|
|
|
+ ImGui::SetClipboardText(buf);
|
|
|
+ sprintf(buf, "(%d,%d,%d,%d)", cr, cg, cb, ca);
|
|
|
+ if (ImGui::Selectable(buf))
|
|
|
+ ImGui::SetClipboardText(buf);
|
|
|
+ sprintf(buf, (flags & ImGuiColorEditFlags_NoAlpha) ? "0x%02X%02X%02X" : "0x%02X%02X%02X%02X", cr, cg, cb, ca);
|
|
|
+ if (ImGui::Selectable(buf))
|
|
|
+ ImGui::SetClipboardText(buf);
|
|
|
+ ImGui::EndPopup();
|
|
|
+ }
|
|
|
+
|
|
|
g.ColorEditOptions = opts;
|
|
|
ImGui::EndPopup();
|
|
|
}
|
|
|
@@ -9295,7 +9326,7 @@ static void ColorPickerOptionsPopup(ImGuiColorEditFlags flags, float* ref_col)
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
if (allow_opt_picker)
|
|
|
{
|
|
|
- ImVec2 picker_size(g.FontSize * 8, ImMax(g.FontSize * 8 - (ColorSquareSize() + g.Style.ItemInnerSpacing.x), 1.0f)); // FIXME: Picker size copied from main picker function
|
|
|
+ ImVec2 picker_size(g.FontSize * 8, ImMax(g.FontSize * 8 - (SmallSquareSize() + g.Style.ItemInnerSpacing.x), 1.0f)); // FIXME: Picker size copied from main picker function
|
|
|
ImGui::PushItemWidth(picker_size.x);
|
|
|
for (int picker_type = 0; picker_type < 2; picker_type++)
|
|
|
{
|
|
|
@@ -9335,7 +9366,8 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
|
|
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
const ImGuiStyle& style = g.Style;
|
|
|
- const float w_extra = (flags & ImGuiColorEditFlags_NoSmallPreview) ? 0.0f : (ColorSquareSize() + style.ItemInnerSpacing.x);
|
|
|
+ const float square_sz = SmallSquareSize();
|
|
|
+ const float w_extra = (flags & ImGuiColorEditFlags_NoSmallPreview) ? 0.0f : (square_sz + style.ItemInnerSpacing.x);
|
|
|
const float w_items_all = CalcItemWidth() - w_extra;
|
|
|
const char* label_display_end = FindRenderedTextEnd(label);
|
|
|
|
|
|
@@ -9353,7 +9385,7 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
|
|
|
|
|
// Context menu: display and modify options (before defaults are applied)
|
|
|
if (!(flags & ImGuiColorEditFlags_NoOptions))
|
|
|
- ColorEditOptionsPopup(flags);
|
|
|
+ ColorEditOptionsPopup(flags, col);
|
|
|
|
|
|
// Read stored options
|
|
|
if (!(flags & ImGuiColorEditFlags__InputsMask))
|
|
|
@@ -9466,7 +9498,6 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
|
|
TextUnformatted(label, label_display_end);
|
|
|
Separator();
|
|
|
}
|
|
|
- float square_sz = ColorSquareSize();
|
|
|
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__InputsMask | ImGuiColorEditFlags_NoLabel | ImGuiColorEditFlags_AlphaPreviewHalf;
|
|
|
PushItemWidth(square_sz * 12.0f); // Use 256 + bar sizes?
|
|
|
@@ -9583,7 +9614,8 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
|
|
|
// Setup
|
|
|
bool alpha_bar = (flags & ImGuiColorEditFlags_AlphaBar) && !(flags & ImGuiColorEditFlags_NoAlpha);
|
|
|
ImVec2 picker_pos = window->DC.CursorPos;
|
|
|
- float bars_width = ColorSquareSize(); // Arbitrary smallish width of Hue/Alpha picking bars
|
|
|
+ float square_sz = SmallSquareSize();
|
|
|
+ float bars_width = square_sz; // Arbitrary smallish width of Hue/Alpha picking bars
|
|
|
float sv_picker_size = ImMax(bars_width * 1, CalcItemWidth() - (alpha_bar ? 2 : 1) * (bars_width + style.ItemInnerSpacing.x)); // Saturation/Value picking box
|
|
|
float bar0_pos_x = picker_pos.x + sv_picker_size + style.ItemInnerSpacing.x;
|
|
|
float bar1_pos_x = bar0_pos_x + bars_width + style.ItemInnerSpacing.x;
|
|
|
@@ -9695,7 +9727,6 @@ bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags fl
|
|
|
if (!(flags & ImGuiColorEditFlags_NoSidePreview))
|
|
|
{
|
|
|
ImVec4 col_v4(col[0], col[1], col[2], (flags & ImGuiColorEditFlags_NoAlpha) ? 1.0f : col[3]);
|
|
|
- float square_sz = ColorSquareSize();
|
|
|
if ((flags & ImGuiColorEditFlags_NoLabel))
|
|
|
Text("Current");
|
|
|
ColorButton("##current", col_v4, (flags & (ImGuiColorEditFlags_HDR|ImGuiColorEditFlags_AlphaPreview|ImGuiColorEditFlags_AlphaPreviewHalf|ImGuiColorEditFlags_NoTooltip)), ImVec2(square_sz * 3, square_sz * 2));
|