| 30 | void ButtonCore::clicked() { _clickCallback.fire(); } |
| 31 | |
| 32 | void ButtonCore::textChanged(const Text &text) |
| 33 | { |
| 34 | std::visit( |
| 35 | [&jView = this->_jButton](auto &&arg) { |
| 36 | using T = std::decay_t<decltype(arg)>; |
| 37 | |
| 38 | if constexpr (std::is_same_v<T, std::string>) { |
| 39 | // Remove '\r' as android treats them as a space |
| 40 | std::string textToSet = arg; |
| 41 | textToSet.erase( |
| 42 | std::remove_if(textToSet.begin(), textToSet.end(), [](unsigned char x) { return x == '\r'; }), |
| 43 | textToSet.end()); |
| 44 | jView.setText(textToSet); |
| 45 | } else if constexpr (std::is_same_v<T, std::shared_ptr<AttributedString>>) { |
| 46 | if (auto attrString = std::dynamic_pointer_cast<bdn::android::AttributedString>(arg)) { |
| 47 | jView.setText(attrString->spanned()); |
| 48 | } |
| 49 | } |
| 50 | }, |
| 51 | text); |
| 52 | |
| 53 | markDirty(); |
| 54 | scheduleLayout(); |
| 55 | } |
| 56 | |
| 57 | void ButtonCore::imageChanged(const std::string &url) { _jButton.setImage(url); } |
| 58 | } |