From 92f21917b1d56b0cf7cd54640e248a9e2602018f Mon Sep 17 00:00:00 2001 From: Mike Nolan Date: Sat, 12 Jul 2025 03:33:45 -0500 Subject: [PATCH] Get more done on packageserver --- Templates/gui/.crossarchiveignore | 2 ++ Templates/gui/cross.json | 26 ++++++++++++++ Templates/gui/res/layout.json | 33 ++++++++++++++++++ Templates/gui/src/main.tcross | 18 ++++++++++ .../src/pages/api/api.tcross | 14 ++++++++ .../src/pages/api/v1.tcross | 34 +++++++++++++++++++ Tesses.CrossLang.Shell/src/app/app.tcross | 10 ++++++ 7 files changed, 137 insertions(+) create mode 100644 Templates/gui/.crossarchiveignore create mode 100644 Templates/gui/cross.json create mode 100644 Templates/gui/res/layout.json create mode 100644 Templates/gui/src/main.tcross create mode 100644 Tesses.CrossLang.PackageServer/src/pages/api/api.tcross create mode 100644 Tesses.CrossLang.PackageServer/src/pages/api/v1.tcross create mode 100644 Tesses.CrossLang.Shell/src/app/app.tcross diff --git a/Templates/gui/.crossarchiveignore b/Templates/gui/.crossarchiveignore new file mode 100644 index 0000000..1746e32 --- /dev/null +++ b/Templates/gui/.crossarchiveignore @@ -0,0 +1,2 @@ +bin +obj diff --git a/Templates/gui/cross.json b/Templates/gui/cross.json new file mode 100644 index 0000000..ba81d53 --- /dev/null +++ b/Templates/gui/cross.json @@ -0,0 +1,26 @@ +{ + "dependencies": [ + ], + "info": { + "template_extra_text_ftles": [ + "res/layout.json" + ], + "template_ignored_files": [ + "bin", + "obj" + ], + "template_info": { + "type": "app", + "license": "MIT" + }, + "template_name": "gui", + "template_project_dependencies": [ + ], + "repo": "https://onedev.site.tesses.net/CrossLang/CrossLangExtras", + "homepage": "https://crosslang.tesseslanguage.com/", + "type": "template", + "description": "A crosslang gui, using tesses-framework's gui library" + }, + "name": "Tesses.CrossLang.Template.GUI", + "version": "1.0.0.0-prod" +} \ No newline at end of file diff --git a/Templates/gui/res/layout.json b/Templates/gui/res/layout.json new file mode 100644 index 0000000..eea4a62 --- /dev/null +++ b/Templates/gui/res/layout.json @@ -0,0 +1,33 @@ +{ + "Child": { + "Type": "AbsoluteView", + "Items": [ + { + "Bounds": { + "X": 42, + "Y": 42, + "Width": 200, + "Height": 50 + }, + "Type": "ButtonView", + "Text": "Click Me", + "Id": "btn1", + "Active": true + } + ] + }, + "Palette": { + "IsDarkMode": true, + "Accent": "#DB0", + "Border": "#040", + "BorderActive":"#A00", + "BorderHover": "#00A", + "BorderHoverActive": "#A0A", + "FontSize": 20 + }, + "Size": { + "Width": 640, + "Height": 480 + }, + "Text": "%PROJECT_NAME%" +} \ No newline at end of file diff --git a/Templates/gui/src/main.tcross b/Templates/gui/src/main.tcross new file mode 100644 index 0000000..87c79a2 --- /dev/null +++ b/Templates/gui/src/main.tcross @@ -0,0 +1,18 @@ +func btn1_Click(sender,e) +{ + Console.WriteLine("Button Clicked"); +} +func main(args) +{ + if(TypeOf(GUI) != "Dictionary") + { + Console.WriteLine("The GUI is not supported, please build tessesframework with TESSESFRAMEWORK_ENABLE_SDL2."); + return 1; + } + var window = GUI.Window.FromJSON(embed("layout.json"), SDL2.Window.Resizable); + var btn1 = window.FindViewById("btn1"); + btn1.Click += btn1_Click; + VM.RunEventLoop(); + btn.Click -= btn1_Click; + window.Dispose(); //we need to destroy it or it will leak +} diff --git a/Tesses.CrossLang.PackageServer/src/pages/api/api.tcross b/Tesses.CrossLang.PackageServer/src/pages/api/api.tcross new file mode 100644 index 0000000..8f583c4 --- /dev/null +++ b/Tesses.CrossLang.PackageServer/src/pages/api/api.tcross @@ -0,0 +1,14 @@ +func Pages.API.Index() +{ + var pages=[{ + active = true, + route = "/api", + text = "API Home" + }]; + var html = +

API Home

+
; + return Shell("CPKG API Home", pages,html); +} \ No newline at end of file diff --git a/Tesses.CrossLang.PackageServer/src/pages/api/v1.tcross b/Tesses.CrossLang.PackageServer/src/pages/api/v1.tcross new file mode 100644 index 0000000..a0206d1 --- /dev/null +++ b/Tesses.CrossLang.PackageServer/src/pages/api/v1.tcross @@ -0,0 +1,34 @@ +func Pages.API.V1() +{ + var pages=[{ + active = false, + route = "/api", + text = "API Home" + }]; + var html = +

API v1

+ +
; + return Shell("CPKG API v1", pages,html); +} \ No newline at end of file diff --git a/Tesses.CrossLang.Shell/src/app/app.tcross b/Tesses.CrossLang.Shell/src/app/app.tcross new file mode 100644 index 0000000..bf981c4 --- /dev/null +++ b/Tesses.CrossLang.Shell/src/app/app.tcross @@ -0,0 +1,10 @@ +func Tesses.CrossLang.Shell.App(dd) +{ + if(dd.Arguments.Count == 1) + { + var window = new GUI.Window("CrossLang",640,480,SDL2.Window.Resizable); + window.View = new GUI.ButtonView("My Favorite Button"); + + VM.RunEventLoop(); + } +} \ No newline at end of file