| 7 | namespace fl { |
| 8 | |
| 9 | class JsonUiTitleInternal : public JsonUiInternal { |
| 10 | private: |
| 11 | fl::string mText; |
| 12 | |
| 13 | public: |
| 14 | // Constructor: Initializes the base JsonUiInternal with name, and sets the |
| 15 | // title text. |
| 16 | JsonUiTitleInternal(const fl::string &name, const fl::string &text) |
| 17 | FL_NOEXCEPT : JsonUiInternal(name), mText(text) {} |
| 18 | |
| 19 | // Override toJson to serialize the title's data directly. |
| 20 | // This function will be called by JsonUiManager to get the component's |
| 21 | // state. |
| 22 | void toJson(fl::json &json) const FL_NOEXCEPT override { |
| 23 | json.set("name", name()); |
| 24 | json.set("type", "title"); |
| 25 | json.set("group", |
| 26 | groupName()); // Assuming groupName() is accessible from base |
| 27 | json.set("id", id()); // Assuming id() is accessible from base |
| 28 | json.set("text", mText); |
| 29 | } |
| 30 | |
| 31 | // Override updateInternal. Titles typically don't have update functionality |
| 32 | // from the UI, so this can be a no-op. |
| 33 | void updateInternal(const fl::json &json) FL_NOEXCEPT override { |
| 34 | // No update needed for title components |
| 35 | FL_UNUSED(json); |
| 36 | } |
| 37 | |
| 38 | // Accessors for the title text. |
| 39 | const fl::string &text() const FL_NOEXCEPT { return mText; } |
| 40 | void setText(const fl::string &text) FL_NOEXCEPT { mText = text; } |
| 41 | }; |
| 42 | |
| 43 | // Constructor implementation |
| 44 | JsonTitleImpl::JsonTitleImpl(const fl::string &name, const fl::string &text) FL_NOEXCEPT { |