From 935675a35a82d4ffd20772e4089d36a465bdf31f Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Thu, 15 Jul 2021 10:24:11 +0200 Subject: [PATCH] Committed our own changes in ImGUI, see commits 042880ba2df913916b2cc77f7bb677e07bfd2c58 67c55c74901f1d337ef08f2090a87cfb4263bb0f a94c952b40d36b1505fb77b87c0dd739e1034659 b3f8ae5ca75b52ef74e8da2be2392ea8339dcab2 2455df4017e4000347dc77b543c8674bd052b145 3ca3a544a87cc569b69351a77996c287763388a5 870aba8d15ec572460a1e288ed26b4718f4f3d0f 62c2095fe8297688c254ef70d9742f18fffe1b77 This should contain exactly the same changes. --- src/imgui/imconfig.h | 31 ++++++++++++++++++++++++++++--- src/imgui/imgui_draw.cpp | 21 +++++++++++++++++++++ 2 files changed, 49 insertions(+), 3 deletions(-) diff --git a/src/imgui/imconfig.h b/src/imgui/imconfig.h index ce60ddf48..5dd6ec608 100644 --- a/src/imgui/imconfig.h +++ b/src/imgui/imconfig.h @@ -113,9 +113,34 @@ //#define IMGUI_DEBUG_PARANOID //---- Tip: You can add extra functions within the ImGui:: namespace, here or in your own headers files. -/* + namespace ImGui { - void MyFunction(const char* name, const MyMatrix44& v); + // Special ASCII character is used here as markup symbols for tokens to be highlighted as a for hovered item + const char ColorMarkerHovered = 0x1; // STX + + // Special ASCII characters STX and ETX are used here as markup symbols for tokens to be highlighted. + const char ColorMarkerStart = 0x2; // STX + const char ColorMarkerEnd = 0x3; // ETX + + // Special ASCII characters are used here as an ikons markers + const char PrintIconMarker = 0x4; + const char PrinterIconMarker = 0x5; + const char PrinterSlaIconMarker = 0x6; + const char FilamentIconMarker = 0x7; + const char MaterialIconMarker = 0x8; + const char CloseNotifButton = 0xB; + const char CloseNotifHoverButton = 0xC; +// const char TimerDotMarker = 0xE; +// const char TimerDotEmptyMarker = 0xF; + const char MinimalizeButton = 0xE; + const char MinimalizeHoverButton = 0xF; + const char WarningMarker = 0x10; + const char ErrorMarker = 0x11; + const char EjectButton = 0x12; + const char EjectHoverButton = 0x13; + const char CancelButton = 0x14; + const char CancelHoverButton = 0x15; +// void MyFunction(const char* name, const MyMatrix44& v); } -*/ + diff --git a/src/imgui/imgui_draw.cpp b/src/imgui/imgui_draw.cpp index 54490ed1a..ab184928f 100644 --- a/src/imgui/imgui_draw.cpp +++ b/src/imgui/imgui_draw.cpp @@ -34,6 +34,8 @@ Index of this file: #endif #include "imgui_internal.h" +#include "imconfig.h" + #ifdef IMGUI_ENABLE_FREETYPE #include "misc/freetype/imgui_freetype.h" #endif @@ -3564,6 +3566,14 @@ void ImFont::RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col const ImU32 col_untinted = col | ~IM_COL32_A_MASK; + ImU32 defaultCol = col; + ImU32 highlighCol = ImGui::GetColorU32(ImGuiCol_ButtonHovered); + // if text is started with ColorMarkerHovered symbol, we should use another color for a highlighting + if (*s == ImGui::ColorMarkerHovered) { + highlighCol = ImGui::GetColorU32(ImGuiCol_FrameBg); + s += 1; + } + while (s < text_end) { if (word_wrap_enabled) @@ -3592,6 +3602,17 @@ void ImFont::RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col } } + if (*s == ImGui::ColorMarkerStart) { + col = highlighCol; + s += 1; + } + else if (*s == ImGui::ColorMarkerEnd) { + col = defaultCol; + s += 1; + if (s == text_end) + break; + } + // Decode and advance source unsigned int c = (unsigned int)*s; if (c < 0x80)