diff --git a/commons/schemas/json-component.schema.json b/commons/schemas/json-component.schema.json
index f1593680..4fa53dff 100644
--- a/commons/schemas/json-component.schema.json
+++ b/commons/schemas/json-component.schema.json
@@ -144,6 +144,10 @@
"const": "string",
"type": "string"
},
+ {
+ "const": "path",
+ "type": "string"
+ },
{
"const": "color",
"type": "string"
@@ -221,6 +225,10 @@
"const": "string",
"type": "string"
},
+ {
+ "const": "path",
+ "type": "string"
+ },
{
"const": "color",
"type": "string"
diff --git a/docs/developers/building.md b/docs/developers/building.md
index e69de29b..4f3031bc 100644
--- a/docs/developers/building.md
+++ b/docs/developers/building.md
@@ -0,0 +1 @@
+TODO: Move material in here from index.md
\ No newline at end of file
diff --git a/docs/developers/todo.md b/docs/developers/todo.md
index a785bccb..532de8d1 100644
--- a/docs/developers/todo.md
+++ b/docs/developers/todo.md
@@ -4,9 +4,9 @@
- [ ] libfltk and its subdeps are compiled into `/app/lib64`, which is not covered by paths
Investigation got results. Basically, all cmake libraries are in `/app/lib` while those through meson are in `/app/lib64` which is not added to the search path in that image.
- Even outside of flatpak this problem occurs, just with different folder names. I must ensure cmake and meson behave the same.
+ Even outside of flatpak this problem occurs, just with different folder names. I must ensure cmake and meson behave the same.
- [ ] commons are not mounted in `/usr/local/share`. I must pass the relevant vars (already supported).
- I must register a variable in the user with where these files are located? Or embed it during compilation? Still not sure.
+ I must register a variable in the user with where these files are located? Or embed it during compilation? Still not sure.
- [ ] Icons, signature and few more things are still missing.
### Scripts
@@ -87,6 +87,8 @@ does not somehow. But just `./two-buttons.xml` does? Check why!
- [x] Unable to append args to meson setup
- [ ] Escape vs_debug (tabs).
- [ ] Add TESTING flag in scripts to determine if some content should be run or not.
+- [ ] Add contextual information in app and component (keys, policies & paths). Remove them from ui_tree as they can be accessed via root.
+ - [ ] Once that is done, properly implement the path type for props, to resolve correctly.
### Scripting
diff --git a/examples/example-0.xml b/examples/example-0.xml
index 0da01a10..da87377b 100644
--- a/examples/example-0.xml
+++ b/examples/example-0.xml
@@ -5,7 +5,7 @@
-
+
@@ -45,19 +45,20 @@
-
+
diff --git a/examples/module-example-btn.xml b/examples/module-example-btn.xml
index 64288fcd..35d53289 100644
--- a/examples/module-example-btn.xml
+++ b/examples/module-example-btn.xml
@@ -1,9 +1,10 @@
-
+
diff --git a/examples/module-example-root.xml b/examples/module-example-root.xml
index 7918ca8c..e1f96d41 100644
--- a/examples/module-example-root.xml
+++ b/examples/module-example-root.xml
@@ -1,7 +1,7 @@
-
-
-
-
+
+
+
+
\ No newline at end of file
diff --git a/include/components/containers.hpp b/include/components/containers.hpp
index 6316a706..03c868be 100644
--- a/include/components/containers.hpp
+++ b/include/components/containers.hpp
@@ -11,39 +11,43 @@
namespace vs{
-class ui_root_app :public ui_base{
- protected:
- cache::ctx_t cache_ctx;
-
+class ui_root_thin_component :public ui_base{
public:
- ui_root_app(frame_mode_t MODE):ui_base(nullptr){
+ ui_root_thin_component(frame_mode_t MODE):ui_base(nullptr){
//Cannot use mk_frame as it requires recursion and the widget property to operate.
local_frame=new frame(nullptr, MODE, this, nullptr, default_frame_type(), frame_access_t::PUBLIC);
}
virtual frame_type_t default_frame_type() override {return frame_type_t::CONTAINER;}
- virtual const char* class_name() override{return "root";}
+ virtual const char* class_name() override{return "component.thin";}
int apply_prop(const char *prop, const char *value) override{if(local_frame!=nullptr)return local_frame->call_dispatcher(prop,value);return 1;}
int get_computed(const char *prop, const char **value) override{return 1;}
};
-class ui_root_component :public ui_base{
+class ui_root_component :public ui_root_thin_component{
protected:
+ cache::ctx_t cache_ctx;
+ policies_t policies; //Computed policies for this tree
+ scoped_rpath_t local; //Full path for the location of this component.
+ scoped_rpath_t fullname; //Full path for the location of this component.
+
public:
- ui_root_component(frame_mode_t MODE):ui_base(nullptr){
- //Cannot use mk_frame as it requires recursion and the widget property to operate.
- local_frame=new frame(nullptr, MODE, this, nullptr, default_frame_type(), frame_access_t::PUBLIC);
- }
+ ui_root_component(frame_mode_t MODE):ui_root_thin_component(MODE){}
- virtual frame_type_t default_frame_type() override {return frame_type_t::CONTAINER;}
virtual const char* class_name() override{return "component";}
+};
+
- int apply_prop(const char *prop, const char *value) override{if(local_frame!=nullptr)return local_frame->call_dispatcher(prop,value);return 1;}
- int get_computed(const char *prop, const char **value) override{return 1;}
+class ui_root_app :public ui_root_component{
+ public:
+ ui_root_app(frame_mode_t MODE):ui_root_component(MODE){}
+
+ virtual const char* class_name() override{return "app";}
};
+
//TODO: Add a new ui_region similar to namespace but with extra cache::ctx_t like app, to nest a new "safe" region inside.
class ui_namespace : public ui_base{
diff --git a/include/ui-tree.hpp b/include/ui-tree.hpp
index 0ca8ff89..1431c082 100644
--- a/include/ui-tree.hpp
+++ b/include/ui-tree.hpp
@@ -8,7 +8,7 @@ namespace vs {
struct ui_tree {
enum class type_t{
- NONE, APP, COMPONENT, FRAGMENT
+ NONE, APP, COMPONENT, COMPONENT_THIN, FRAGMENT
}type;
//Define the embedded mode supported.
diff --git a/schemas/components/fl:window.json b/schemas/components/fl:window.json
index fad5bc56..5aad333f 100644
--- a/schemas/components/fl:window.json
+++ b/schemas/components/fl:window.json
@@ -1,13 +1,22 @@
{
- "$schema": "../../commons/schemas/json-component.schema.json",
- "description": "Base element to a window",
- "usable": true,
- "type": "node",
- "headers": ["FL/Fl_Window.H"],
- "extends": "fl:base",
- "codegen": {"extends": "ui"},
- "props":{
+ "$schema": "../../commons/schemas/json-component.schema.json",
+ "description": "Base element to a window",
+ "usable": true,
+ "type": "node",
+ "headers": ["FL/Fl_Window.H", "FL/Fl_SVG_Image.H"],
+ "extends": "fl:base",
+ "codegen": { "extends": "ui" },
+ "props": {
+ "border": {
+ "type": "flag",
+ "description": "True if using a border around",
+ "code": "w.border(computed);"
},
- "computed":{
+ "icon": {
+ "type": "string",
+ "description": "True if using a border around",
+ "code": "w.icon(new Fl_SVG_Image(value));"
}
-}
\ No newline at end of file
+ },
+ "computed": {}
+}
diff --git a/schemas/vs-ns.json b/schemas/vs-ns.json
index dea72cb5..9aa60cfc 100644
--- a/schemas/vs-ns.json
+++ b/schemas/vs-ns.json
@@ -1,24 +1,18 @@
{
- "elements":[
- "app",
- "component",
- "static-data",
- "import",
- "use",
- "slot",
- "viewport",
- "data.",
- "script",
- "mixin",
- "debug",
- "namespace"
- ],
-
- "attributes":[
- "src.",
- "name",
- "frame.",
- "template",
- "mixins"
- ]
-}
\ No newline at end of file
+ "elements": [
+ "app",
+ "component",
+ "static-data",
+ "import",
+ "use",
+ "slot",
+ "viewport",
+ "data.",
+ "script",
+ "mixin",
+ "debug",
+ "namespace"
+ ],
+
+ "attributes": ["src.", "name", "frame.", "template", "mixins"]
+}
diff --git a/scripts/codegen/components-new.schema.ts b/scripts/codegen/components-new.schema.ts
index 5028d2ba..6b17e255 100644
--- a/scripts/codegen/components-new.schema.ts
+++ b/scripts/codegen/components-new.schema.ts
@@ -7,6 +7,7 @@ export const type_schema = t.Union([
t.Literal('flag'),
t.Literal('enum'),
t.Literal('raw'),
+ t.Literal('path'),
t.Literal('string'),
t.Literal('color'),
t.Literal('scalar-1'),
diff --git a/scripts/codegen/components.schema.ts b/scripts/codegen/components.schema.ts
index 2c74d3f8..9771fb56 100644
--- a/scripts/codegen/components.schema.ts
+++ b/scripts/codegen/components.schema.ts
@@ -1,20 +1,20 @@
import { Type as t } from "@sinclair/typebox"
-export const type_schema = t.Union([t.Literal('flag'), t.Literal('enum'), t.Literal('raw'), t.Literal('string'), t.Literal('color'), t.Literal('scalar-1'), t.Literal('scalar-2'), t.Literal('scalar-4')], { description: 'type', default: 'string' });
+export const type_schema = t.Union([t.Literal('flag'), t.Literal('enum'), t.Literal('raw'), t.Literal('string'), t.Literal('path'), t.Literal('color'), t.Literal('scalar-1'), t.Literal('scalar-2'), t.Literal('scalar-4')], { description: 'type', default: 'string' });
const entries_schema = t.Record(t.String(), t.Object({
type: type_schema,
subtype: t.Optional(t.String()),
- code: t.Union([t.String(),t.Null()], {default:null}),
+ code: t.Union([t.String(), t.Null()], { default: null }),
description: t.Optional(t.String()),
- alias: t.Optional(t.Array(t.String(), { description: "alias names" , default:[]}))
+ alias: t.Optional(t.Array(t.String(), { description: "alias names", default: [] }))
}))
export const widget_schema = t.Object({
$schema: t.Optional(t.String()),
ns: t.Optional(t.String()),
name: t.Optional(t.String()),
- usable: t.Optional(t.Boolean({default:true})),
+ usable: t.Optional(t.Boolean({ default: true })),
description: t.Optional(t.String()),
use_main_header: t.Union([t.Null(), t.String()], { default: null }),
headers: t.Optional(t.Array(t.String())),
@@ -26,7 +26,7 @@ export const widget_schema = t.Object({
computed_tail: t.Optional(t.Union([t.Null(), t.String()])),
}, { additionalProperties: false }),
extends: t.Union([t.Null(), t.String()], { default: null }),
- skip_props: t.Optional(t.Array(t.String(),{default:[],description:"Properties to be matched but ignored"})),
+ skip_props: t.Optional(t.Array(t.String(), { default: [], description: "Properties to be matched but ignored" })),
props: entries_schema,
computed: entries_schema,
}, { additionalProperties: false })
\ No newline at end of file
diff --git a/scripts/codegen/gen-components.tsx b/scripts/codegen/gen-components.tsx
index bae9b216..186f9d3c 100644
--- a/scripts/codegen/gen-components.tsx
+++ b/scripts/codegen/gen-components.tsx
@@ -23,6 +23,7 @@ function make_type_code(type: Static, subtype: string, code:
else if (type === 'scalar-2') return `size_t computed[2]; if((ok = field_types::h_px(2,computed,value,that))){${code}}`
else if (type === 'scalar-4') return `size_t computed[4]; if((ok = field_types::h_px(4,computed,value,that))){${code}}`
else if (type === 'enum') return `int computed = field_types::${subtype}_i(value);if((ok=(computed!=-1))){${code}}`
+ else if (type === 'path') return `/*TODO*/`
}
function gen_cpp(data: Static) {
@@ -35,7 +36,7 @@ function gen_cpp(data: Static) {
#include
#include
${cextends ? `#include \n` : ``}
-${data.headers ? data.headers.map(x => `#include <${x}>\n`) : ``}
+${data.headers ? data.headers.map(x => `#include <${x}>\n`).join('\n') : ``}
namespace vs{
diff --git a/src/ui-tree.xml.cpp b/src/ui-tree.xml.cpp
index e0ffedb3..22ef3282 100755
--- a/src/ui-tree.xml.cpp
+++ b/src/ui-tree.xml.cpp
@@ -196,9 +196,18 @@ int ui_tree_xml::build(){
//cache_ctx.computed_key = key256compose(token, cache_ctx.computed_key);
cache_ctx.page_tag = xml_root.attribute("page").as_string("");
}
+ else if(type==type_t::COMPONENT && xml_root.attribute("thin").as_bool(false)==false){
+ base = (ui_base*)new ui_root_component(frame_mode_t::AUTO);
+ //TODO: Handle app.class token & page tag
+
+ auto token = string2key256(xml_root.attribute("class-token").as_string(nullptr), cache_ctx.src_key);
+ //cache_ctx.computed_key = key256compose(token, cache_ctx.computed_key);
+ cache_ctx.page_tag = xml_root.attribute("page").as_string("");
+ }
else base = caller_ui_node;
- _build(doc.child((type==type_t::APP)?strings.APP_TAG:strings.COMPONENT_TAG),(type==type_t::APP)?base:caller_ui_node);
+ _build(doc.child(
+ (type==type_t::APP)?strings.APP_TAG:strings.COMPONENT_TAG), base);
if(type==type_t::APP)root=base;
else root = nullptr;
@@ -317,7 +326,7 @@ void ui_tree_xml::_build(const pugi::xml_node& root, ui_base* root_ui){
}
}
- else if (strcmp(root.name(),"component")==0){}
+ else if (strcmp(root.name(),strings.COMPONENT_TAG)==0){}
# if __has_include("./ui.xml-widgets.autogen.cpp")
# include "./ui.xml-widgets.autogen.cpp"
@@ -523,14 +532,11 @@ void ui_tree_xml::_build_base_widget_extended_attr(const pugi::xml_node &root, u
_build_base_widget_extended_attr(root, (ui_base *)current);
-
+ //TODO: Check if this has still any effect
if(strcmp(root.parent().name(),strings.APP_TAG)==0){
current->reparent_frame(root_ui);
}
-
-
-
//TODO: Optimize copies
smap props = current->compute_refresh_style(root.attribute("mixin").as_string(""));
/*{auto tmp = current->compile_mixins((std::string("+")+root.name()).data()); for(const auto& i: tmp)props.insert_or_assign(i.first,std::move(i.second));}
@@ -560,7 +566,6 @@ void ui_tree_xml::_build_base_widget_extended_attr(const pugi::xml_node &root, u
if(strcmp(i.name(),"src")!=0)props.insert_or_assign(i.name(), i.value());
}
}
-
for (const auto &i : root.attributes()) {
props.insert_or_assign(i.name(), i.value());