@@ -244,6 +244,11 @@ bool Dialog::TextInputWithImplicitApply(const string& label, string& currentValu
244244 return false ;
245245}
246246
247+ bool Dialog::TextInputWithExplicitApply (const string& label, string& currentValue, string& committedValue)
248+ {
249+ return renderEditablePropertyWithExplicitApply (-1 ,label,currentValue,committedValue,Unit ()/* not used for string*/ );
250+ }
251+
247252bool Dialog::IntInputWithImplicitApply (const string& label, int & currentValue, int & committedValue)
248253{
249254 bool dirty = currentValue != committedValue;
@@ -495,7 +500,7 @@ template<typename T>
495500 */
496501bool Dialog::renderEditableProperty (float width, const std::string& label, std::string& currentValue, T& committedValue, Unit unit, const char * tooltip, std::optional<ImVec4> optcolor, bool allow7SegmentDisplay, bool explicitApply)
497502{
498- static_assert (std::is_same_v<T, float > || std::is_same_v<T, double > || std::is_same_v<T, int64_t >, " renderEditableProperty only supports int64_t, float or double" );
503+ static_assert (std::is_same_v<T, float > || std::is_same_v<T, double > || std::is_same_v<T, int64_t > || std::is_same_v<T, std::string>, " renderEditableProperty only supports string, int64_t, float or double" );
499504 bool use7Segment = false ;
500505 bool changeFont = false ;
501506 int64_t displayType = NumericValueDisplay::NUMERIC_DISPLAY_DEFAULT_FONT;
@@ -535,6 +540,8 @@ bool Dialog::renderEditableProperty(float width, const std::string& label, std::
535540 }
536541 if constexpr (std::is_same_v<T, int64_t >)
537542 dirty = unit.PrettyPrintInt64 (committedValue) != currentValue;
543+ else if constexpr (std::is_same_v<T, std::string>)
544+ dirty = committedValue != currentValue;
538545 else
539546 dirty = unit.PrettyPrint (committedValue) != currentValue;
540547 string editLabel = label+" ##Edit" ;
@@ -681,6 +688,10 @@ bool Dialog::renderEditableProperty(float width, const std::string& label, std::
681688
682689 currentValue = unit.PrettyPrintInt64 (committedValue);
683690 }
691+ else if constexpr (std::is_same_v<T, std::string>)
692+ {
693+ committedValue = currentValue;
694+ }
684695 else
685696 {
686697 committedValue = static_cast <T>(unit.ParseString (currentValue));
@@ -696,6 +707,8 @@ bool Dialog::renderEditableProperty(float width, const std::string& label, std::
696707 { // Restore value
697708 if constexpr (std::is_same_v<T, int64_t >)
698709 currentValue = unit.PrettyPrintInt64 (committedValue);
710+ else if constexpr (std::is_same_v<T, std::string>)
711+ currentValue = committedValue;
699712 else
700713 currentValue = unit.PrettyPrint (committedValue);
701714 if (m_editedItemId == editId)
@@ -714,6 +727,7 @@ bool Dialog::renderEditableProperty(float width, const std::string& label, std::
714727template bool Dialog::renderEditableProperty<float >(float width, const std::string& label, std::string& currentValue, float & committedValue, Unit unit, const char * tooltip, std::optional<ImVec4> optcolor, bool allow7SegmentDisplay, bool explicitApply);
715728template bool Dialog::renderEditableProperty<double >(float width, const std::string& label, std::string& currentValue, double & committedValue, Unit unit, const char * tooltip, std::optional<ImVec4> optcolor, bool allow7SegmentDisplay, bool explicitApply);
716729template bool Dialog::renderEditableProperty<int64_t >(float width, const std::string& label, std::string& currentValue, int64_t & committedValue, Unit unit, const char * tooltip, std::optional<ImVec4> optcolor, bool allow7SegmentDisplay, bool explicitApply);
730+ template bool Dialog::renderEditableProperty<std::string>(float width, const std::string& label, std::string& currentValue, std::string& committedValue, Unit unit, const char * tooltip, std::optional<ImVec4> optcolor, bool allow7SegmentDisplay, bool explicitApply);
717731
718732template <typename T>
719733/* *
@@ -738,7 +752,24 @@ bool Dialog::renderEditablePropertyWithExplicitApply(float width, const std::str
738752template bool Dialog::renderEditablePropertyWithExplicitApply<float >(float width, const std::string& label, std::string& currentValue, float & committedValue, Unit unit, const char * tooltip, std::optional<ImVec4> optcolor, bool allow7SegmentDisplay);
739753template bool Dialog::renderEditablePropertyWithExplicitApply<double >(float width, const std::string& label, std::string& currentValue, double & committedValue, Unit unit, const char * tooltip, std::optional<ImVec4> optcolor, bool allow7SegmentDisplay);
740754template bool Dialog::renderEditablePropertyWithExplicitApply<int64_t >(float width, const std::string& label, std::string& currentValue, int64_t & committedValue, Unit unit, const char * tooltip, std::optional<ImVec4> optcolor, bool allow7SegmentDisplay);
755+ template bool Dialog::renderEditablePropertyWithExplicitApply<std::string>(float width, const std::string& label, std::string& currentValue, std::string& committedValue, Unit unit, const char * tooltip, std::optional<ImVec4> optcolor, bool allow7SegmentDisplay);
741756
757+ /* *
758+ @brief Render a badge with text inside
759+ @param width the width of the badge
760+ @param color the badge color
761+ @param label the text of the badge
762+ */
763+ void Dialog::renderBadge (float width, ImVec4 color, const string& label)
764+ {
765+ float fontSize = ImGui::GetFontSize ();
766+ if (width <= 0 ) width = 6 *fontSize;
767+ ImGui::PushStyleColor (ImGuiCol_ChildBg, color);
768+ ImGui::BeginChild (" ##badge" , ImVec2 (width, ImGui::GetFontSize ()),false ,ImGuiWindowFlags_None);
769+ ImGui::TextUnformatted (label.c_str ());
770+ ImGui::EndChild ();
771+ ImGui::PopStyleColor ();
772+ }
742773
743774/* *
744775 @brief Segment on/off state for each of the 10 digits + "L" (needed for OL / Overload)
0 commit comments