| 46 | } |
| 47 | |
| 48 | void LabelCore::textChanged(const Text &text) |
| 49 | { |
| 50 | if (_currentAttributedString) { |
| 51 | _currentAttributedString->linkClicked().unsubscribe(_linkSubscription); |
| 52 | } |
| 53 | |
| 54 | std::visit( |
| 55 | [this](auto &&arg) { |
| 56 | using T = std::decay_t<decltype(arg)>; |
| 57 | |
| 58 | if constexpr (std::is_same_v<T, std::string>) { |
| 59 | // Remove '\r' as android treats them as a space |
| 60 | std::string textToSet = arg; |
| 61 | textToSet.erase( |
| 62 | std::remove_if(textToSet.begin(), textToSet.end(), [](unsigned char x) { return x == '\r'; }), |
| 63 | textToSet.end()); |
| 64 | _jLabel.setText(textToSet); |
| 65 | } else if constexpr (std::is_same_v<T, std::shared_ptr<AttributedString>>) { |
| 66 | if (auto attrString = std::dynamic_pointer_cast<bdn::android::AttributedString>(arg)) { |
| 67 | _currentAttributedString = attrString; |
| 68 | _linkSubscription = _currentAttributedString->linkClicked().subscribe( |
| 69 | [this](auto url) { this->_linkClickCallback.fire(url); }); |
| 70 | _jLabel.setText(attrString->spanned()); |
| 71 | } |
| 72 | } |
| 73 | }, |
| 74 | text); |
| 75 | |
| 76 | markDirty(); |
| 77 | scheduleLayout(); |
| 78 | } |
| 79 | |
| 80 | void LabelCore::updateTruncateAndWrapMode() |
| 81 | { |
nothing calls this directly
no test coverage detected