Separating Blender's Data-Model from the GUI

When reading Ton’s
“(Re)defining Blender”, I found it interesting to see, that one of the problems for enhancing the current GUI
is the strong connection of the data model and the graphic interface.

Ton:
“The misconception here is that the “UI” is some kind of separated entity of a program, which can just be peeled off and replaced with another interface. However, a really good UI (and certainly Blender’s) is not just an abstract independent layer, it’s the reflection (and sometimes even the core) of the program’s design.”

Actually for my understanding a “really good GUI” should not be dependent on internal implementation and data structures but instead communicate through a lighter protocol by using more generic and simpler data structures.

I understand, that sometimes this is not possible, for example when having real BIG data, but in most cases the presentation layer will not need access to the implementation details of the data model.

When I last looked into the code, some years ago, I was able to separate the GHOST parts to compile blenderless on my Mac. I did that just to see the coupling of the parts and to see, if my I would be able to help programming blender.
It was hard, especially with outdated/undated docs and sparing code comments. Based on my findings, I decided, I could not help in blender development, because it would eat up too much of my resources.

Maybe now is the time to look again, with all the GUI discussion startet by Andrew Price. This thread should be

  • a research about the current implementation (finding out how its working internally)
  • suggestions to enhance and separate the model/gui communication
  • looking for a replacement of GHOST, for example GLFW http://www.glfw.org/
  • document and simplify how user can build scripted GUI panels

Thanks to everyone which can help here with details and to all developers which did a great job to make Blender the outstanding application it is today. :wink:

Thank you

There are many ways that a UI becomes attached to the underlying data model without relying explicitly on internal implementation details.

For example, it is straight forward to have a cube in a scene, and to add an array and subsurf modifier to that cube. The Blender data model is that modifiers are owned by objects in a scene. The UI depends on this in that if you want to add a modifier to something, first you have to click that object then Blender can show you a meaningful modifier panel.

If somebody came up with a new UI workflow for building objects entirely from modifiers, this would be pretty difficult to implement in Blender. It would not be a simple matter of “remove the UI and replace with a new one” because Blender is designed to work with modifiers attached to objects as a core concept.

I’m doubtful that it is possible to design a non-trivial program that will not have this issue.

I like the idea about decoupling data model and GUI, but I am very confused about this talk about GHOST. In my mind, the data model in Blender is the DNA/RNA system.

Edit: or do you want the other way around, the GUI without the data model?

GHOST is Blenders OpenGL system.

Ton’s take on this http://www.youtube.com/watch?v=Huh8Din7Exc&feature=share&t=39m15s

I know what it is, but why would you want to use GHOST outside Blender?
First, it doesn’t have nearly as many options as GTK or Qt.
Second, unlike GTK or Qt, the GPL will bite you.
Third, as Ton says in the video, the Blender UI is tied tightly to Blender’s technology.

I don’t want use GHOST, I wrote that I’d like to replace GHOST with something like GLFW. In order to
understand, what Ghost does in Blender, I built a special Blender version.

That’s why this thread was started: to decouple this and because I don’t share the opinion, that all is fine, leave it as it is.

Yes, that repeats, what he already wrote. I understand his arguments. I don’t share them.

@hewi
Sure, I will share the code,
its a while since I did that Ghost thing, let me look into my Time-Machine…

Either your time machine is seriously broken and unable to recover the files or you were joking and I again did not get the clue that it is not really possible any more to recover these long forgotten files.

But still I am waiting in greatest anticipation

Edit: added question

Why would you want to replace the GHOST Toolkit?

Hey Pixwang,

Any news on the code you wanted to share?

regards

Hewi

Code is here:http://www.visiomedia.com/tmp/ghost_test_0.2.1.zip

Hewi:Why would you want to replace the GHOST Toolkit?

Just personal taste, I will no longer invest time in that GHOST library.

Hey Pixwang,

  • are you actually developing a blender gui standalone?

  • you want to replace the GHOST with something like GLFW. Have you, by making this choise, looked up all the possible alternatives. For example if you would be writing the standalone in SDL (SimpleDirectmediaLayer www.libsdl.org), you get sound and joystick and all ‘for free’:

Simple DirectMedia Layer is a cross-platform development library designed to provide low level access to audio, keyboard, mouse, joystick, and graphics hardware via OpenGL and Direct3D. …
SDL officially supports Windows, Mac OS X, Linux, iOS, and Android. Support for other platforms may be found in the source code.
SDL is written in C, works natively with C++, and there are bindings available for several other languages, including C# and Python.

  • Why am I spending so much time in extracting the GHOST out of blender and am I not just using QT or GTK or wxWidgets or any other library out there which are also cross platform to create windows and then just pluggin in blender, like sjoerd said?

Thanks for sharing code and ideas

Kindest regards

Hewi

hey Sjoerd,

What do you actually mean with “the (GHOST) GPL will bite you”?

Blender gui is not bad, is actually very good but is sure very outdated. It needs to get more controls, be more intuitive. This my top personal example on how Blender GUI would work. AvalonDock http://avalondock.codeplex.com/. You get all of these different controls, docking capabilities, tabs, everything is awesome. In WPF you get the presentation customized with declarative syntax which leads to great possibilities for creative control, e.g. themes, behaviours (animations).

It’s two birds with a stone.
More controls, more design.


Also another one, I really liked what Firefox did with their Firefox OS, they provided a GUI layer in all HTML5, that means that you can hack everything on the shell, without breaking the nerves of system developers. This is a pure MVC technique at it’s best, and is a no joke situation.


I don’t know exactly if you are into HTML, you might think that this is somehow dump idea, but trust me on this, HTML is highly customizable and very robust. Also by means of productivity you get thousand times less effort to create superb interfaces.
For example let’s say that you wanted to put a galaxy wallpaper on the text editor window, you just go and do it with no coding skills at all. In another case lets say you want to do 3D flip transitions while opening menus, you just do it.

In any case I guess that HTML5 wins big here:

  1. It leads to rapid results (you have every technology available).

  2. No legal disturbs, you go fully open source (e.g. Webkit renderer).

  3. You get standardized specifications (everything you create within a standard is OK because anyone can follow it. Also provided that standards have passed tremendous and extensive fail-success cycles, lots of people have put their minds into it and did the dirty work to clear things up).

  4. You get maximum compatibility (HTML specs are tested by millions of computer users, no need to argue about it).

  5. You get like zero bugs on the rendering system (handled by the renderer team e.g. Webkit. Sidenote: Looks like I am obsessed with Webkit right? I have not problem whatever it is, perhaps Google’s Blink might be good as well, dunno).

  6. More robust (instead of creating GUI systems, you simply create the GUI).

  7. Costs less development effort (the Blender team brings all the focus on the system, the Blender GUI team simply makes it visual).

The bottom line is: “Will it Blend?” So let the benchmarks begin! Start hacking and find out.

@pixwang read your initial message - I think you misunderstand Ton.

Internal data stricture is for example…

  • A scene has an active object
  • objects reference object data
  • Each object has one action and optionally NLA
  • A pose is linked to an object not armature.

An interface must preset this data in a logical way- said different - you cant ignore the relationships between data when making an interface.

@pixwang - regarding replacing GHOST, Im not sure why you would do this…
For example, I made GHOST use SDL2 as a test (and to support more platforms). But I could have removed GHOST and just used SDL,

If I had done this, what would be the advantage? (Ok, so we dont have to maintain ghost… ) but ghost is already a very thin wrapper on the OS.

In fact there are likely good reasons to keep ghost - Similar libraries - thin OpenGL wrappers are often used for games (SDL, allegro, clanlib) dont have tablet (wacom) support and dont manage multiple windows.

Libraries that DO support tablets,multi-touch,multi-win — Qt and GTK we could use but then we depend on them just so we can have an opengl surface to draw on, which seems overkill.

Hey All,

Sorry to be asking all these questions but I would, at all costs, like to avoid reinventing ‘the wheel’ and also fully understand what is going on with this GUI separation, so I will pose them anyway:

@pixwang
-> could you be so kind to look at post #14, there are 3 questions for you there

@sjoerd
-> could you be so kind to look at post #15, there are 3 questions for you there

@const
-> WPF == Windows Presentation Foundation … microsoft … mmmmh, let’s not go there!? let’s keep it ‘open’.

-> html5, I am actively developing websites using html, css, javascript, php, mysql, apache; even though I am in strong agreement with your arguments of html being all you posted, I just can’t convince myself we would be able to implement blender into a browser user interface. you said so yourself: “The bottom line is: Will it Blend?”. Maybe if you could provide some examples. It is definitely worth the thought.

@ideasman
-> GHOST is indeed a very thin layer as wrapper for the OpenGL libs, so why keep it? you need to, next to GHOST, still implement sound and media links and python API. None of this would be necessary with SDL?

-> SDL libs have a whole community by itself supporting the code maintanace, and it is a big community, so it is unlikely the SDL will disapear soon. On the contrary, maybe we can join forces? united we stand.

-> QT/GTK implementing multiple windows and ipods and such. The latest release notes of SDL indicates just that: http://freecode.com/projects/sdl

2.0.1 11 Nov 2013 04:08 Major feature enhancements
Release Notes: Support has been added for OpenGL ES, OGL3, for multiple windows, displays, and audio devices, and for Android, iOS, and the Raspberry Pi. GLES2 rendering performance has been improved.

The main question here is indeed, why not use QT or GTK or wxWdgets instead of recreating a new GUI?

Regards to all

thanks for time and energy

Hewi

Personally, I feel that Ton wasn’t suggesting any interface violation was in practice, but instead that the GUI infers a certain data model, or that the data model infers a certain GUI. Anyone used to writing software will be accustomed to finding natural methods of expressing data that needs to be used in a certain way. It can still be generic enough that it is non specialised in how it’s stored, but it is best suited to access in a certain way. For example, say we have a Python list of n objects, and the order is important. It is possible to read the items in any order, but being able to say that we can perform some kind of lookup on the first item saves us time, rather than looping through (this is a poor example, but shares the sentiment of inferred dependencies)

@hewi - SDL2 isn’t a drop-in replacement for GHOST.

  • No tablet support
  • No support for continuous grab (could be added but currently not)
  • Limited access to windowing - progress bar on win and osx, window stacking.
  • Text input method is different to GHOST, can’t get unicode character for each key hit.
  • No wayland support yet - (there is a Blender git repo with basic support)

As for GTK/QT - moving Blenders windowing and UI to another toolkit is a huge project, so sure it can be done but not simply.

@agoose77, re #20, exactly!