From 04e852c45a3f309d5e139b0ca059b32277c250e4 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Tue, 6 Apr 2021 06:16:47 +0200 Subject: Create a unified launcher for quickmedia --- src/Text.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'src/Text.cpp') diff --git a/src/Text.cpp b/src/Text.cpp index a9f1147..2abc276 100644 --- a/src/Text.cpp +++ b/src/Text.cpp @@ -29,15 +29,16 @@ namespace QuickMedia Text::Text(bool bold_font) : Text("", bold_font, 0, 0.0f) {} - Text::Text(sf::String _str, bool bold_font, unsigned int _characterSize, float _maxWidth) : + Text::Text(sf::String _str, bool bold_font, unsigned int characterSize, float maxWidth, bool highlight_urls) : bold_font(bold_font), - characterSize(_characterSize), - maxWidth(_maxWidth), + characterSize(characterSize), + maxWidth(maxWidth), color(sf::Color::White), dirty(true), dirtyText(false), dirtyCaret(false), editable(false), + highlight_urls(highlight_urls), caretMoveDirection(CaretMoveDirection::NONE), num_lines(1), lineSpacing(0.0f), @@ -324,10 +325,14 @@ namespace QuickMedia dirtyText = false; splitTextByFont(); // TODO: Optimize - auto u8 = str.toUtf8(); - std::string *u8_str = (std::string*)&u8; - url_ranges = extract_urls(*u8_str); - convert_utf8_to_utf32_ranges(*u8_str, url_ranges); + if(highlight_urls) { + auto u8 = str.toUtf8(); + std::string *u8_str = (std::string*)&u8; + url_ranges = extract_urls(*u8_str); + convert_utf8_to_utf32_ranges(*u8_str, url_ranges); + } else { + url_ranges.clear(); + } dirty = true; } -- cgit v1.2.3