Commit fa5d8b52 authored by jan.koester's avatar jan.koester
Browse files

label support

parent 8100ce07
Loading
Loading
Loading
Loading
+16 −0
Changes for editor/widgets/button/button.cpp: 16 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ extern "C" {
        class Button : public EditPlugin {
        private:
            std::string label           = "Click Me";
            bool hideLabel              = false;
            std::string linkUrl         = "#";
            std::string linkType        = "url";    // "url" or "section"
            std::string sectionId       = "";       // target section instance id
@@ -129,6 +130,16 @@ extern "C" {
                lblInput.setAttribute("value", label.c_str());
                settings.appendChild(lblInput);

                // Hide Label
                libhtmlpp::HtmlElement hlLabel("label");
                hlLabel.appendChild(libhtmlpp::TextElement("Hide Label: "));
                settings.appendChild(hlLabel);
                libhtmlpp::HtmlElement hlInput("input");
                hlInput.setAttribute("type", "checkbox");
                hlInput.setAttribute("name", "hide_label");
                if (hideLabel) hlInput.setAttribute("checked", "checked");
                settings.appendChild(hlInput);

                // Link Type
                libhtmlpp::HtmlElement ltLabel("label");
                ltLabel.appendChild(libhtmlpp::TextElement("Link Type: "));
@@ -351,6 +362,11 @@ extern "C" {
                    return o;
                };
                addField("label", "Button Label", "text");
                addField("hide_label", "Hide Label", "checkbox");
                {
                    json_object *hf = json_object_array_get_idx(arr, json_object_array_length(arr) - 1);
                    json_object_object_add(hf, "default", json_object_new_boolean(false));
                }
                addField("link_type", "Link Type", "select", nullptr, "all", mkOpts({"url","section"}));
                addField("link_url", "Link URL", "text", "https://...", "all", nullptr, mkVisible("link_type","url"));
                addField("open_new_tab", "Open in New Tab", "checkbox", nullptr, "all", nullptr, mkVisible("link_type","url"));