A replacement for CSS.. For desktop apps

The title is vague, so I’ll explain.
I was frustrated with UI dev (in general), and even more-so when working with a application that needed OpenGL with embedded UI. What if I wanted to make a full application with OpenGL? (Custom game engine anyone?)
Well I did want to. And I’m working on it right now. But it started me onto making what I think is a great idea of a styling language;
I present KSS (pron. Kiss) The multitudes more programmable version of CSS… (only for desktop dev)


BUT
It also has some cool things. I’ve taken the liberty to add variables, templates (style inheritance), hierarchy-selection, events (as objects), native function calls, in-file functions.

But wait, you ask… what If I need to select items from a hierarchy? Surely using element names and id’s couldn’t be robust enough!
Well… there’s an app for that:

The last things to note are event-pointers, how tagging works, ‘this’, and general workflow.
Tagging works (basically) the same as Unity, you say @tagName : tagValue inside a styling field to assign that element a tag that’s referable in the application.
You have the ability to refer to any variable you assign within the styling sheet, from say… source-code. The backend. As such, being able to set a variable to ‘this’ (the element being styled) allows you to operate with buttons who are currently in focus, or set the parent of an item to another element.
All elements are available to use as variables inside and outside the styling sheet, so an event can effectively parent an element or group of elements to a UI you specify. Ill show that in a figure below,
Event pointers are so that you can trigger an event with a UI component, but affect another, below-

image
Lastly: The results/workflow.
I’m in the process of building my first (serious) game engine after learning OpenGL, and I’m building it with Kotlin and Python. I can bind both Kotlin and Python functions for use inside the styling sheet, and although I didn’t show the layout-language (cause its honestly not good), this is the result after a day of work so far, while using these two UI languages I’ve made


It’s also important to note that while it does adopt the CSS Box-model, it is not a Cascading layout.
That’s all I had to show. Essentially, right now Its a Kotlin -backed creation, but can be made for Java specifically, C++, C#, … Lua? etc. I’m planning on adding more into the language to make it even more robust. What’s more, it doesn’t need to be OpenGL backed- it can use Java paint classes, SFML, … Roblox Studio? etc etc. I just need to standardize the API for it. I guess what I’m wondering is, if I put it out there- would anyone want to use it for desktop application dev?
P.S. Of course the syntax is subject to change, via suggestion.
P.S.[2] The image in the middle of the editor is static, but wont be when I put 3D scenes in the scene-view.
P.S.[3] Sorry everyone, the syntax highlighting is only css rn. so it looks like garbo.

Here’s the GitHub/Wiki for it.

7 Likes

The second I saw “fun” I was like “Kotlin?” lol

Also how did you make this?

I would actually love to see the source code for this, or at least some form of library later on. This looks pretty interesting. I am a heavy programmer in Java, and a c++ version would be great as well. :slightly_smiling_face:

http://wiki.qt.io/About_Qt

In general it seems a lot like re-inventing the wheel.

I do currently use qt, but I would still like to see how you did it.

You produce a Abstract-Syntax-Tree from the source (in this case a .kss file), and walk the tree. In my implementation, for the sake of optimization, it only walks the tree once and stores proxy objects storing the important information in what you might call a Proxy-Object-Tree(?). All the objects who reference eachother have that built into the classes for speed as well.

templates and functions are top-level declarations, where only functions can be embedded into other functions or style fields- so traversing this Proxy-Object-Tree is pretty fast; and calling or referring to the programmable parts is fast because there’s no scope/environment inspection- the implementation knows you’ll always find templates or functions or run-immediately styles/events at a hierarchy depth of 0.

Its basically as “mark-up” as it needs to be for speed, and as programmable as we want for functionality

1 Like

Sorry for bumping guys, I just wanted to say I’ve made the library public under my GitHub. There’s complete syntax documentation, a JVM implementation, a link to download, and a quick-start guide.

I hope you all enjoy :slight_smile:

As cool as this is… I have to point out that this is a massive violation of everything that CSS stands for. The very purpose of CSS is to separate the styling / layout of a page / UI / etc from the content / behavior of that content. Adding scriptability back into CSS is going full circle… and not in a good way.

That’s not to say it won’t be useful for some, but it’s a bit counterintuitive of an endeavour.

If you want more ideas you might also want to look at the SASS CSS preprocessor, (here’s a general overview of what CSS preprocessors do), it does similar things to some of what you’re doing.

1 Like

SASS is what I primarily use for my job. Love it

That makes me cri cri, though I was thinking of turning the language into a CSS+JavaScript "PP"
I probably should have pointed out an over-all philosophy

But ig this is the opportunity.

It’s mostly exactly as you said on purpose- its meant to place more control into the developers hands (as far as behavior goes), and allow easier large-project-management; though those being said- it should also be noted its predominantly in the spirit of keeping any additional functionality design/style centric, instead of arbitrarily programming with it- if that makes sense.