Cross platform GUI for D. Widgets, layouts, styles, themes, unicode, i18n, OpenGL based acceleration.
GitHub page: https://github.com/buggins/dlangui
Project site: http://buggins.github.io/dlangui
API Documentation: http://buggins.github.io/dlangui/ddox
Wiki: https://github.com/buggins/dlangui/wiki/Home
Getting Started Tutorial: https://github.com/buggins/dlangui/wiki/Getting-Started
Screenshots: http://buggins.github.io/dlangui/screenshots.html
Coding style: https://github.com/buggins/dlangui/blob/master/CODING_STYLE.md
BeamUI - actual fork of DlangUI - in active development : https://github.com/dayllenger/beamui
WARNING: dependencies in dlangui/deps now are git submodules (if you previously cloned them into deps directory, remove deps dir before updating dlangui project)
Main features:
Needs DMD frontend 2.077 or newer to build
Currently implemented widgets:
Similar to layouts in Android
Lists are implemented similar to Android UI API.
Resources like fonts and images use reference counting. For proper resource freeing, always destroy widgets implicitly.
Styles and themes are a bit similar to ones in Android API.
If build of your app is failed due to dlangui or its dependencies, probably you have not upgraded dependencies.
Try following:
dub upgrade --force-remove
dub build --force
As well, sometimes removing of dub.json.selections can help.
Build and run demo app using DUB:
git clone --recursive https://github.com/buggins/dlangui.git
cd dlangui/examples/example1
dub run --build=release
To develop using Visual-D or MonoD, open dlangui.sln using Visual D (or dlangui-monod.sln for MonoD)
To avoid showing console window add win_app.def file to your package source directory and add line to your dub.json.
win_app.def:
"sourceFiles": ["$PACKAGE_DIR/src/win_app.def"]
dub.json:
"sourceFiles-windows": ["$PACKAGE_DIR/src/win_app.def"],
DMD, DUB, git, MonoDevelop with Mono-D plugin must be installed
Can use SDL2 or X11 as a backend.
Native Cocoa backend - work is in progress.
In some directory, e.g. ~/src/d/ :
Clone DlangUI repository
git clone --recursive https://github.com/buggins/dlangui.git
Enter dlangui directory
cd dlangui
Open solution file with Mono-D
dlangui-monod-osx.sln
Install DUB, DMD, MonoDevelop with Mono-D plugin.
Required libraries: libsdl2, x11, libfreetype, libfontconfig and OpenGL.
Clone DlangUI repository
git clone https://github.com/buggins/dlangui.git
Enter dlangui directory
cd dlangui
Open solution file with Mono-D
dlangui-monod-linux.sln
Try running examples: helloworld, example1, tetris, dmledit, spreadsheet, opengl
Configurations Debug, Release, Unittest build SDL2+OpenGL versions of apps.
Configurations DebugMinimal, ReleaseMinimal, UnittestMinimal build pure SDL2 versions of apps.
If you are creating your own solution / project which uses DlangUI in Mono-D:
Following settings are to be applied to all configurations of your new project (Debug, Release, Unittest):
In your project options Build/Project Dependencies - mark dlangui-monod-linux item
In your project options Build/Compiling/Linking - check "Link in static/shared libraries from nested dependencies"
In your project options Build/Compiling/Compiling - specify Version constants as "USE_OPENGL;USE_SDL;USE_FREETYPE;EmbedStandardResources" (EmbedStandardResources is required if you want to embed your own additional resources into executable)
If your project needs to embed some resources into executable (usually from "views" directory), specify all directories which contain resources in Build/Compiling/Compiling/Extra Compiler Options, e.g.:
-Jviews
-Jviews/res
-Jviews/res/i18n
-Jviews/res/mdpi
-Jviews/res/hdpi
In your project options Build/Includes put list of import directories of DlangUI library and its dependencies, like
../dlangui/src
../dlangui/deps/DerelictSDL2/source
../dlangui/deps/DerelictFT/source
../dlangui/deps/DerelictGL3/source
../dlangui/deps/DerelictUtil/source
../dlangui/3rdparty
Now you can build and run your project.
To hack DlangIDE project, you can clone it from https://github.com/buggins/dlangide.git into the same directory dlangui is cloned to. Then just open solution dlangide/dlangide-monod-linux.sln with mono-d.
Install GIT, DUB, DMD, MonoDevelop with Mono-D plugin.
Clone DlangUI repository
git clone https://github.com/buggins/dlangui.git
Enter dlangui directory
cd dlangui
Open solution file with Mono-D
dlangui-monod-windows.sln
Try running examples: helloworld, example1, tetris, dmledit, spreadsheet, opengl
Configurations Debug, Release, Unittest build SDL2+OpenGL versions of apps.
Configurations DebugMinimal, ReleaseMinimal, UnittestMinimal build pure win32 versions of apps w/o OpenGL.
If you are creating your own solution / project which uses DlangUI in Mono-D:
Following settings are to be applied to all configurations of your new project (Debug, Release, Unittest):
In your project options Build/Project Dependencies - mark dlangui-monod-linux item
In your project options Build/Compiling/Linking - check "Link in static/shared libraries from nested dependencies"
In your project options Build/Compiling/Compiling - specify Version constants as "USE_FREETYPE;USE_OPENGL;EmbedStandardResources;Unicode;windows" (EmbedStandardResources is required if you want to embed your own additional resources into executable)
If your project needs to embed some resources into executable (usually from "views" directory), specify all directories which contain resources in Build/Compiling/Compiling/Extra Compiler Options, e.g.:
-Jviews
-Jviews/res
-Jviews/res/i18n
-Jviews/res/mdpi
-Jviews/res/hdpi
In your project options Build/Includes put list of import directories of DlangUI library and its dependencies, like
../dlangui/src
../dlangui/3rdparty
../dlangui/deps/DerelictSDL2/source
../dlangui/deps/DerelictFT/source
../dlangui/deps/DerelictGL3/source
../dlangui/deps/DerelictUtil/source
Now you can build and run your project.
To hack DlangIDE project, you can clone it from https://github.com/buggins/dlangide.git into the same directory dlangui is cloned to. Then just open solution dlangide/dlangide-monod-linux.sln with mono-d.
Install GIT, DUB, DMD, MS Visual Studio (e.g. Community 2013) + VisualD plugin
Clone DlangUI repository
git clone --recursive https://github.com/buggins/dlangui.git
For DlangIDE development, close dlangide project on the same directory level as dlangui is cloned:
git clone --recursive https://github.com/buggins/dlangide.git
Enter dlangui directory
cd dlangui
Open solution file with Visual-D
dlangui-msvc.sln
Try running examples: helloworld, example1, tetris, dmledit, spreadsheet, opengl
Configurations Debug, Release, Unittest build SDL2+OpenGL versions of apps.
Configurations DebugMinimal, ReleaseMinimal, UnittestMinimal build pure win32 versions of apps w/o OpenGL.
If you are creating your own solution / project which uses DlangUI in Mono-D:
Following settings are to be applied to all configurations of your new project (Debug, Release, Unittest):
In your project options Build/Project Dependencies - mark dlangui-monod-linux item
In your project options Build/Compiling/Linking - check "Link in static/shared libraries from nested dependencies"
In your project options Build/Compiling/Compiling - specify Version constants as "USE_FREETYPE;USE_OPENGL;EmbedStandardResources;Unicode;windows" (EmbedStandardResources is required if you want to embed your own additional resources into executable)
If your project needs to embed some resources into executable (usually from "views" directory), specify all directories which contain resources in Build/Compiling/Compiling/Extra Compiler Options, e.g.:
-Jviews
-Jviews/res
-Jviews/res/i18n
-Jviews/res/mdpi
-Jviews/res/hdpi
In your project options Build/Includes put list of import directories of DlangUI library and its dependencies, like
../dlangui/src
../dlangui/deps/DerelictSDL2/source
../dlangui/deps/DerelictFT/source
../dlangui/deps/DerelictGL3/source
../dlangui/deps/DerelictUtil/source
Now you can build and run your project.
To hack DlangIDE project, you can clone it from https://github.com/buggins/dlangide.git into the same directory dlangui is cloned to. Then just open solution dlangide/dlangide-monod-linux.sln with mono-d.
Uses SDL2 as a backend.
Uses FreeType for font rendering.
Uses FontConfig to get list of available fonts.
OpenGL is can be optionally used for better drawing performance.
libsdl2, libfreetype, libfontconfig
E.g. in Ubuntu, you can use following command to enable SDL2 backend builds:
sudo apt-get install libsdl2-dev
In runtime, .so for following libraries are being loaded (binary packages required):
freetype, opengl, fontconfig
Build and run on Linux using DUB:
cd examples/example1
dub run dlangui:example1
// myproject.d
import dlangui;
mixin APP_ENTRY_POINT;
/// entry point for dlangui based application
extern (C) int UIAppMain(string[] args) {
// create window
Window window = Platform.instance.createWindow("My Window", null);
// create some widget to show in window
window.mainWidget = (new Button()).text("Hello world"d).textColor(0xFF0000); // red text
// show window
window.show();
// run message loop
return Platform.instance.enterMessageLoop();
}
{
"name": "myproject",
"description": "sample DLangUI project",
"targetPath": "bin",
"targetType": "executable",
"dependencies": {
"dlangui": "~master"
}
}
DlangUI supports creation of widgets from markup.
DML - DlangUI Markup Language - similar to QML.
Example of complex UI easy created from text:
module app;
import dlangui;
mixin APP_ENTRY_POINT;
/// entry point for dlangui based application
extern (C) int UIAppMain(string[] args) {
// create window
Window window = Platform.instance.createWindow("DlangUI example - HelloWorld", null);
// create some widget to show in window
//window.mainWidget = (new Button()).text("Hello, world!"d).margins(Rect(20,20,20,20));
window.mainWidget = parseML(q{
VerticalLayout {
margins: 10
padding: 10
backgroundColor: "#C0E0E070" // semitransparent yellow background
// red bold text with size = 150% of base style size and font face Arial
TextWidget { text: "Hello World example for DlangUI"; textColor: "red"; fontSize: 150%; fontWeight: 800; fontFace: "Arial" }
// arrange controls as form - table with two columns
TableLayout {
colCount: 2
TextWidget { text: "param 1" }
EditLine { id: edit1; text: "some text" }
TextWidget { text: "param 2" }
EditLine { id: edit2; text: "some text for param2" }
TextWidget { text: "some radio buttons" }
// arrange some radio buttons vertically
VerticalLayout {
RadioButton { id: rb1; text: "Item 1" }
RadioButton { id: rb2; text: "Item 2" }
RadioButton { id: rb3; text: "Item 3" }
}
TextWidget { text: "and checkboxes" }
// arrange some checkboxes horizontally
HorizontalLayout {
CheckBox { id: cb1; text: "checkbox 1" }
CheckBox { id: cb2; text: "checkbox 2" }
}
}
HorizontalLayout {
Button { id: btnOk; text: "Ok" }
Button { id: btnCancel; text: "Cancel" }
}
}
});
// you can access loaded items by id - e.g. to assign signal listeners
auto edit1 = window.mainWidget.childById!EditLine("edit1");
auto edit2 = window.mainWidget.childById!EditLine("edit2");
// close window on Cancel button click
window.mainWidget.childById!Button("btnCancel").click = delegate(Widget w) {
window.close();
return true;
};
// show message box with content of editors
window.mainWidget.childById!Button("btnOk").click = delegate(Widget w) {
window.showMessageBox(UIString("Ok button pressed"d),
UIString("Editors content\nEdit1: "d ~ edit1.text ~ "\nEdit2: "d ~ edit2.text));
return true;
};
// show window
window.show();
// run message loop
return Platform.instance.enterMessageLoop();
}
There is DMLEdit sample app in DlangUI/examples directory.
You can run it with dub:
dub run dlangui:dmledit
It allows to edit DML text and see how it will look like when loaded into app (F5 refreshes view).
Syntax highlight, bracket matching, go to error and other useful features are implemented.
It is a project to build D language IDE using DlangUI library.
But it already can open DUB based projects, edit, build and run them.
Simple syntax highlight.
DCD integration: go to definition and autocompletion for D source code.
Project page: https://github.com/buggins/dlangide
How to build and run using DUB:
git clone https://github.com/buggins/dlangide.git
cd dlangide
dub run