diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a79975..92d30e0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -395,6 +395,7 @@ IF(APPLE) set(PLATFORM_LIBS "-framework CoreFoundation" "-framework Appkit" + "-licuio -licui18n -licuuc" ) ELSE(APPLE) @@ -404,7 +405,7 @@ ELSE(APPLE) ${IMGUITEXTEDIT_SRC} ) - set(PLATFORM_LIBS "" + set(PLATFORM_LIBS "-licuio -licui18n -licuuc" ) ENDIF(APPLE) diff --git a/ImageShader.cpp b/ImageShader.cpp index 89e241d..2539894 100644 --- a/ImageShader.cpp +++ b/ImageShader.cpp @@ -12,7 +12,7 @@ static ShadingProgram imageShadingProgram("shaders/image.vs", "shaders/image.fs" const char* MaskShader::mask_names[4] = { ICON_FA_EXPAND, ICON_FA_CIRCLE, ICON_FA_MINUS_CIRCLE, ICON_FA_SQUARE }; std::vector< ShadingProgram* > MaskShader::mask_programs; -ImageShader::ImageShader(): Shader(), /*mask(0), custom_textureindex(0),*/ stipple(0.0) +ImageShader::ImageShader(): Shader(), stipple(0.0) { // static program shader program_ = &imageShadingProgram; diff --git a/Source.cpp b/Source.cpp index 82de050..577b774 100644 --- a/Source.cpp +++ b/Source.cpp @@ -1,5 +1,5 @@ - #include +#include #include #include @@ -13,6 +13,7 @@ #include "SearchVisitor.h" #include "ImageShader.h" #include "ImageProcessingShader.h" +#include "SystemToolkit.h" #include "Log.h" #include "Mixer.h" @@ -246,10 +247,10 @@ Source::~Source() void Source::setName (const std::string &name) { - name_ = name; + name_ = SystemToolkit::transliterate(name); - initials_[0] = std::toupper( name_.front() ); - initials_[1] = std::toupper( name_.back() ); + initials_[0] = std::toupper( name_.front(), std::locale("en_US.utf8") ); + initials_[1] = std::toupper( name_.back(), std::locale("en_US.utf8") ); } void Source::accept(Visitor& v) diff --git a/SystemToolkit.cpp b/SystemToolkit.cpp index 04b9495..9227016 100644 --- a/SystemToolkit.cpp +++ b/SystemToolkit.cpp @@ -7,6 +7,10 @@ #include #include +#include +#include +#include + using namespace std; #ifdef WIN32 @@ -355,4 +359,23 @@ void SystemToolkit::execute(const string& command) // "gst-launch-1.0 udpsrc port=5000 ! application/x-rtp,encoding-name=JPEG,payload=26 ! rtpjpegdepay ! jpegdec ! autovideosink").detach();; +// Using ICU transliteration : +// https://unicode-org.github.io/icu/userguide/transforms/general/#icu-transliterators +std::string SystemToolkit::transliterate(std::string input) +{ + auto ucs = icu_67::UnicodeString::fromUTF8(input); + + UErrorCode status = U_ZERO_ERROR; + icu::Transliterator *firstTrans = icu::Transliterator::createInstance( + "any-NFKD ; [:Nonspacing Mark:] Remove; NFKC; Latin", UTRANS_FORWARD, status); + firstTrans->transliterate(ucs); + + icu::Transliterator *secondTrans = icu::Transliterator::createInstance( + "any-NFKD ; [:Nonspacing Mark:] Remove; [@!#$*%~] Remove; NFKC", UTRANS_FORWARD, status); + secondTrans->transliterate(ucs); + + std::ostringstream output; + output << ucs; + return output.str(); +} diff --git a/SystemToolkit.h b/SystemToolkit.h index dfb1345..f0bd0fe 100644 --- a/SystemToolkit.h +++ b/SystemToolkit.h @@ -65,6 +65,7 @@ namespace SystemToolkit // try to open the file with system void open(const std::string& path); + // try to execute a command void execute(const std::string& command); @@ -74,6 +75,9 @@ namespace SystemToolkit // get a string to display memory size with unit KB, MB, GB, TB std::string byte_to_string(long b); + + // get a transliteration to Latin of any string + std::string transliterate(std::string input); } #endif // SYSTEMTOOLKIT_H diff --git a/UserInterfaceManager.cpp b/UserInterfaceManager.cpp index aec2e75..a6101b4 100644 --- a/UserInterfaceManager.cpp +++ b/UserInterfaceManager.cpp @@ -2759,129 +2759,95 @@ void ShowSandbox(bool* p_open) ImGui::Text("Testing sandox"); - const guint64 duration = GST_SECOND * 6; - const guint64 step = GST_MSECOND * 20; - static guint64 t = 0; +// const guint64 duration = GST_SECOND * 6; +// const guint64 step = GST_MSECOND * 20; +// static guint64 t = 0; -// bool slider_pressed = ImGuiToolkit::TimelineSlider("timeline", &t, duration, step); +// static float *arr_lines = nullptr; +// static float *arr_histo = nullptr; +// static uint array_size = 200; - static float *arr_lines = nullptr; - static float *arr_histo = nullptr; -// static float arr[] = { 0.6f, 0.1f, 1.0f, 0.5f, 0.92f, 0.1f, 0.2f, 0.f, 1.f, 0.4f, -// 0.6f, 0.1f, 1.0f, 0.5f, 0.92f, 0.1f, 0.2f, 0.f, 1.f, 0.4f, -// 0.6f, 0.1f, 1.0f, 0.5f, 0.92f, 0.1f, 0.2f, 0.f, 1.f, 0.4f, -// 0.6f, 0.1f, 1.0f, 0.5f, 0.92f, 0.1f, 0.2f, 0.f, 1.f, 0.4f, -// 0.6f, 0.1f, 1.0f, 0.5f, 0.92f, 0.1f, 0.2f, 0.f, 1.f, 0.4f, -// 0.6f, 0.1f, 1.0f, 0.5f, 0.92f, 0.1f, 0.2f, 0.f, 1.f, 0.4f, -// 0.6f, 0.1f, 1.0f, 0.5f, 0.92f, 0.1f, 0.2f, 0.f, 1.f, 0.4f, -// 0.6f, 0.1f, 1.0f, 0.5f, 0.92f, 0.1f, 0.2f, 0.f, 1.f, 0.4f, -// 0.6f, 0.1f, 1.0f, 0.5f, 0.92f, 0.1f, 0.2f, 0.f, 1.f, 0.4f, -// 0.6f, 0.1f, 1.0f, 0.5f, 0.92f, 0.1f, 0.2f, 0.f, 1.f, 0.4f, -// 0.6f, 0.1f, 1.0f, 0.5f, 0.92f, 0.1f, 0.2f, 0.f, 1.f, 0.4f, -// 0.6f, 0.1f, 1.0f, 0.5f, 0.92f, 0.1f, 0.2f, 0.f, 1.f, 0.4f, -// 0.6f, 0.1f, 1.0f, 0.5f, 0.92f, 0.1f, 0.2f, 0.f, 1.f, 0.4f, -// 0.6f, 0.1f, 1.0f, 0.5f, 0.92f, 0.1f, 0.2f, 0.f, 1.f, 0.4f, -// 0.6f, 0.1f, 1.0f, 0.5f, 0.92f, 0.1f, 0.2f, 0.f, 1.f, 0.4f, -// 0.6f, 0.1f, 1.0f, 0.5f, 0.92f, 0.1f, 0.2f, 0.f, 1.f, 0.4f, -// 0.6f, 0.1f, 1.0f, 0.5f, 0.92f, 0.1f, 0.2f, 0.f, 1.f, 0.4f, -// 0.6f, 0.1f, 1.0f, 0.5f, 0.92f, 0.1f, 0.2f, 0.f, 1.f, 0.4f, -// 0.6f, 0.1f, 1.0f, 0.5f, 0.92f, 0.1f, 0.2f, 0.f, 1.f, 0.4f, -// 0.6f, 0.1f, 1.0f, 0.5f, 0.92f, 0.1f, 0.2f, 0.f, 1.f, 0.4f, -// 0.6f, 0.1f, 1.0f, 0.5f, 0.92f, 0.1f, 0.2f, 0.f, 1.f, 0.4f, -// 0.6f, 0.1f, 1.0f, 0.5f, 0.92f, 0.1f, 0.2f, 0.f, 1.f, 0.4f, -// 0.6f, 0.1f, 1.0f, 0.5f, 0.92f, 0.1f, 0.2f, 0.f, 1.f, 0.4f }; +// if (arr_lines == nullptr) { - static uint array_size = 200; +// arr_lines = (float *) malloc(array_size * sizeof(float)); +// arr_histo = (float *) malloc(array_size * sizeof(float)); -// MediaPlayer *mp_ = nullptr; -// auto po = MediaPlayer::begin(); -// if (po != MediaPlayer::end()) -// mp_ = *po; -// if (mp_) { - // } -//// duration = mp_->duration(); -//// step = mp_->frameDuration(); -//// t = mp_->position(); +// for (int i = 0; i < array_size; ++i) { +// arr_lines[i] = 1.f; +// arr_histo[i] = 0.f; +// } +// } -//// arr = mp_->timelineArray(); -//// array_size = mp_->timelineArraySize(); - - if (arr_lines == nullptr) { - - arr_lines = (float *) malloc(array_size * sizeof(float)); - arr_histo = (float *) malloc(array_size * sizeof(float)); - - for (int i = 0; i < array_size; ++i) { - arr_lines[i] = 1.f; - arr_histo[i] = 0.f; - } - } - - // scrolling sub-window - ImGui::BeginChild("##scrolling", - ImVec2(ImGui::GetContentRegionAvail().x, 250), - false, ImGuiWindowFlags_HorizontalScrollbar); +// // scrolling sub-window +// ImGui::BeginChild("##scrolling", +// ImVec2(ImGui::GetContentRegionAvail().x, 250), +// false, ImGuiWindowFlags_HorizontalScrollbar); - if (arr_lines != nullptr) - { +// if (arr_lines != nullptr) +// { - ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(1, 1)); - ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 1.f); +// ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(1, 1)); +// ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 1.f); - ImVec2 size = ImGui::CalcItemSize(ImVec2(-FLT_MIN, 0.0f), ImGui::CalcItemWidth(), 40); - size.x *= 1.f; +// ImVec2 size = ImGui::CalcItemSize(ImVec2(-FLT_MIN, 0.0f), ImGui::CalcItemWidth(), 40); +// size.x *= 1.f; -// // draw position when entering -// ImVec2 draw_pos = ImGui::GetCursorPos(); +//// // draw position when entering +//// ImVec2 draw_pos = ImGui::GetCursorPos(); -//// // capture user input -//// uint press_index = array_size-1; -//// float val = 0.f; -//// bool pressed = false; +////// // capture user input +////// uint press_index = array_size-1; +////// float val = 0.f; +////// bool pressed = false; -//// uint starting_index = press_index; -//// pressed = ImGuiToolkit::InvisibleDoubleSliderFloat("test", &press_index, &val, 0, array_size-1, size); -//// if (pressed) -//// { -//// for (int i = MIN(starting_index, press_index); i < MAX(starting_index, press_index); ++i) -//// arr[i] = val; +////// uint starting_index = press_index; +////// pressed = ImGuiToolkit::InvisibleDoubleSliderFloat("test", &press_index, &val, 0, array_size-1, size); +////// if (pressed) +////// { +////// for (int i = MIN(starting_index, press_index); i < MAX(starting_index, press_index); ++i) +////// arr[i] = val; -////// starting_index = press_index; +//////// starting_index = press_index; +////// } + +//// float x = -1.f; +//// float y = -1.f; +//// bool clicked = ImGuiToolkit::InvisibleCoordinatesFloat("test", &x, &y, size); +//// if (clicked) { +//// Log::Info("clic %f %f in [%f %f]", x, y, size.x, size.y); //// } -// float x = -1.f; -// float y = -1.f; -// bool clicked = ImGuiToolkit::InvisibleCoordinatesFloat("test", &x, &y, size); -// if (clicked) { -// Log::Info("clic %f %f in [%f %f]", x, y, size.x, size.y); -// } +//// // back to +//// ImGui::SetCursorPos(draw_pos); +//// // plot lines +//// ImGui::PlotLines("Lines", arr, array_size-1, 0, NULL, 0.0f, 1.0f, size); -// // back to -// ImGui::SetCursorPos(draw_pos); -// // plot lines -// ImGui::PlotLines("Lines", arr, array_size-1, 0, NULL, 0.0f, 1.0f, size); +////// size.y = 20; +////// ImGui::PlotHistogram("Hisfd", arr, array_size-1, 0, NULL, 0.0f, 1.0f, size); +// bool r = false; +// ImGuiToolkit::EditPlotHistoLines("Alpha", arr_histo, arr_lines, array_size, 0.f, 1.f, &r, size); -//// size.y = 20; -//// ImGui::PlotHistogram("Hisfd", arr, array_size-1, 0, NULL, 0.0f, 1.0f, size); - bool r = false; - ImGuiToolkit::EditPlotHistoLines("Alpha", arr_histo, arr_lines, array_size, 0.f, 1.f, &r, size); +// bool slider_pressed = ImGuiToolkit::TimelineSlider("timeline", &t, 0, duration, step, size.x); - bool slider_pressed = ImGuiToolkit::TimelineSlider("timeline", &t, 0, duration, step, size.x); +// ImGui::PopStyleVar(2); - ImGui::PopStyleVar(2); +// ImGui::Text("Timeline t %" GST_STIME_FORMAT "\n", GST_STIME_ARGS(t)); +// ImGui::Text("Timeline Pressed %s", slider_pressed ? "on" : "off"); - ImGui::Text("Timeline t %" GST_STIME_FORMAT "\n", GST_STIME_ARGS(t)); - ImGui::Text("Timeline Pressed %s", slider_pressed ? "on" : "off"); +// static int w = 0; +// ImGui::SetNextItemWidth(size.x); +// ImGui::SliderInt("##int", &w, 0, array_size-1); - static int w = 0; - ImGui::SetNextItemWidth(size.x); - ImGui::SliderInt("##int", &w, 0, array_size-1); +// } - } +// ImGui::EndChild(); - ImGui::EndChild(); + static char str0[128] = "àöäüèáû вторая строчка"; + ImGui::InputText("input text", str0, IM_ARRAYSIZE(str0)); + std::string tra = SystemToolkit::transliterate(std::string(str0)); + ImGui::Text("Transliteration: '%s'", tra.c_str()); ImGui::End(); }