sample project
|
@ -6,3 +6,5 @@ Trying to write D language IDE using dlangUI library.
|
|||
Use DUB to build and run it.
|
||||
|
||||
To develop in VisualD together with DlangUI, put this project on the same level as dlangui repository, and dependencies.
|
||||
|
||||
To run, it needs FreeImage.dll and directory /res in the same directory as executable.
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
module dlangide.ui.commands;
|
||||
|
||||
enum IDEActions : int {
|
||||
None = 0,
|
||||
FileOpen = 10000,
|
||||
FileClose,
|
||||
FileExit,
|
||||
EditCopy = 11000,
|
||||
EditPaste,
|
||||
EditCut,
|
||||
EditUndo,
|
||||
EditRedo,
|
||||
}
|
||||
|
|
@ -189,6 +189,12 @@
|
|||
<filesToClean>*.obj;*.cmd;*.build;*.json;*.dep</filesToClean>
|
||||
</Config>
|
||||
<Folder name="dlangide">
|
||||
<Folder name="dlangide">
|
||||
<Folder name="ui">
|
||||
<File path="commands.d" />
|
||||
<File path="frame.d" />
|
||||
</Folder>
|
||||
</Folder>
|
||||
<File path="src/app.d" />
|
||||
</Folder>
|
||||
</DProject>
|
||||
|
|
|
@ -0,0 +1,113 @@
|
|||
module dlangide.ui.frame;
|
||||
|
||||
import dlangui.widgets.menu;
|
||||
import dlangui.widgets.tabs;
|
||||
import dlangui.widgets.layouts;
|
||||
import dlangui.widgets.editors;
|
||||
import dlangui.widgets.controls;
|
||||
|
||||
import std.conv;
|
||||
|
||||
enum : int {
|
||||
ACTION_FILE_OPEN = 5500,
|
||||
ACTION_FILE_SAVE,
|
||||
ACTION_FILE_CLOSE,
|
||||
ACTION_FILE_EXIT,
|
||||
}
|
||||
|
||||
|
||||
class IDEFrame : VerticalLayout {
|
||||
|
||||
MainMenu mainMenu;
|
||||
MenuItem mainMenuItems;
|
||||
|
||||
this(Window window) {
|
||||
super("IDEFrame");
|
||||
|
||||
|
||||
createMenu();
|
||||
createTabs();
|
||||
|
||||
layoutWidth = FILL_PARENT;
|
||||
layoutHeight = FILL_PARENT;
|
||||
|
||||
//window.mainWidget = this;
|
||||
}
|
||||
|
||||
void createTabs() {
|
||||
TabWidget tabs = new TabWidget("TABS");
|
||||
tabs.layoutWidth = FILL_PARENT;
|
||||
tabs.layoutHeight = FILL_PARENT;
|
||||
|
||||
|
||||
// create Editors test tab
|
||||
VerticalLayout editors = new VerticalLayout("editors");
|
||||
editors.layoutWidth = FILL_PARENT;
|
||||
editors.layoutHeight = FILL_PARENT;
|
||||
EditBox editBox = new EditBox("editbox1", "Some text\nSecond line\nYet another line\n\n\tforeach(s;lines);\n\t\twriteln(s);\n"d);
|
||||
editBox.layoutWidth(FILL_PARENT).layoutHeight(FILL_PARENT);
|
||||
editBox.minFontSize(12).maxFontSize(75); // allow font zoom with Ctrl + MouseWheel
|
||||
editors.addChild(editBox);
|
||||
//editBox.popupMenu = editPopupItem;
|
||||
tabs.addTab(editors, "TAB_EDITORS"c);
|
||||
|
||||
addChild(tabs);
|
||||
|
||||
tabs.selectTab("editors");
|
||||
|
||||
}
|
||||
|
||||
void createMenu() {
|
||||
mainMenuItems = new MenuItem();
|
||||
MenuItem fileItem = new MenuItem(new Action(1, "MENU_FILE"));
|
||||
fileItem.add(new Action(ACTION_FILE_OPEN, "MENU_FILE_OPEN"c, "document-open", KeyCode.KEY_O, KeyFlag.Control));
|
||||
fileItem.add(new Action(ACTION_FILE_SAVE, "MENU_FILE_SAVE"c, "document-save", KeyCode.KEY_S, KeyFlag.Control));
|
||||
fileItem.add(new Action(ACTION_FILE_EXIT, "MENU_FILE_EXIT"c, "document-close"c, KeyCode.KEY_X, KeyFlag.Alt));
|
||||
MenuItem editItem = new MenuItem(new Action(2, "MENU_EDIT"));
|
||||
editItem.add(new Action(EditorActions.Copy, "MENU_EDIT_COPY"c, "edit-copy", KeyCode.KEY_C, KeyFlag.Control));
|
||||
editItem.add(new Action(EditorActions.Paste, "MENU_EDIT_PASTE"c, "edit-paste", KeyCode.KEY_V, KeyFlag.Control));
|
||||
editItem.add(new Action(EditorActions.Cut, "MENU_EDIT_CUT"c, "edit-cut", KeyCode.KEY_X, KeyFlag.Control));
|
||||
editItem.add(new Action(EditorActions.Undo, "MENU_EDIT_UNDO"c, "edit-undo", KeyCode.KEY_Z, KeyFlag.Control));
|
||||
editItem.add(new Action(EditorActions.Redo, "MENU_EDIT_REDO"c, "edit-redo", KeyCode.KEY_Y, KeyFlag.Control));
|
||||
editItem.add(new Action(20, "MENU_EDIT_PREFERENCES"));
|
||||
MenuItem windowItem = new MenuItem(new Action(3, "MENU_WINDOW"c));
|
||||
windowItem.add(new Action(30, "MENU_WINDOW_PREFERENCES"));
|
||||
MenuItem helpItem = new MenuItem(new Action(4, "MENU_HELP"c));
|
||||
helpItem.add(new Action(40, "MENU_HELP_VIEW_HELP"));
|
||||
MenuItem aboutItem = new MenuItem(new Action(41, "MENU_HELP_ABOUT"));
|
||||
helpItem.add(aboutItem);
|
||||
aboutItem.onMenuItemClick = delegate(MenuItem item) {
|
||||
Window wnd = Platform.instance.createWindow("About...", window, WindowFlag.Modal);
|
||||
wnd.mainWidget = createAboutWidget();
|
||||
wnd.show();
|
||||
return true;
|
||||
};
|
||||
mainMenuItems.add(fileItem);
|
||||
mainMenuItems.add(editItem);
|
||||
//mainMenuItems.add(viewItem);
|
||||
mainMenuItems.add(windowItem);
|
||||
mainMenuItems.add(helpItem);
|
||||
mainMenu = new MainMenu(mainMenuItems);
|
||||
addChild(mainMenu);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Widget createAboutWidget()
|
||||
{
|
||||
LinearLayout res = new VerticalLayout();
|
||||
res.padding(Rect(10,10,10,10));
|
||||
res.addChild(new TextWidget(null, "DLangIDE"d));
|
||||
res.addChild(new TextWidget(null, "(C) Vadim Lopatin, 2014"d));
|
||||
res.addChild(new TextWidget(null, "http://github.com/buggins/dlangide"d));
|
||||
res.addChild(new TextWidget(null, "So far, it's just a test for DLangUI library."d));
|
||||
res.addChild(new TextWidget(null, "Later I hope to make working IDE :)"d));
|
||||
Button closeButton = new Button("close", "Close"d);
|
||||
closeButton.onClickListener = delegate(Widget src) {
|
||||
Log.i("Closing window");
|
||||
res.window.close();
|
||||
return true;
|
||||
};
|
||||
res.addChild(closeButton);
|
||||
return res;
|
||||
}
|
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 828 B |
After Width: | Height: | Size: 892 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 2.0 KiB |
|
@ -0,0 +1,32 @@
|
|||
EXIT=Exit
|
||||
MENU_FILE=&File
|
||||
MENU_FILE_OPEN=&Open
|
||||
MENU_FILE_OPEN_RECENT=Open recent
|
||||
MENU_FILE_SAVE=&Save
|
||||
MENU_FILE_EXIT=E&xit
|
||||
MENU_EDIT=&Edit
|
||||
MENU_EDIT_COPY=&Copy
|
||||
MENU_EDIT_PASTE=&Paste
|
||||
MENU_EDIT_CUT=Cu&t
|
||||
MENU_EDIT_UNDO=&Undo
|
||||
MENU_EDIT_REDO=&Redo
|
||||
MENU_EDIT_PREFERENCES=&Preferences
|
||||
MENU_VIEW=&View
|
||||
MENU_VIEW_LANGUAGE=Interface &Language
|
||||
MENU_VIEW_LANGUAGE_EN=English
|
||||
MENU_VIEW_LANGUAGE_RU=Русский
|
||||
MENU_VIEW_THEME=&Theme
|
||||
MENU_VIEW_THEME_DEFAULT=&Default
|
||||
MENU_VIEW_THEME_CUSTOM1=&Custom 1
|
||||
MENU_WINDOW=&Window
|
||||
MENU_WINDOW_PREFERENCES=&Preferences
|
||||
MENU_HELP=&Help
|
||||
MENU_HELP_VIEW_HELP=&View help
|
||||
MENU_HELP_ABOUT=&About
|
||||
|
||||
TAB_LONG_LIST=Long list
|
||||
TAB_BUTTONS=Buttons
|
||||
TAB_ANIMATION=Animation
|
||||
TAB_TABLE_LAYOUT=Table layout
|
||||
TAB_EDITORS=Editors
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
EXIT=Выход
|
||||
MENU_FILE=&Файл
|
||||
MENU_FILE_OPEN=&Открыть
|
||||
MENU_FILE_OPEN_RECENT=Открыть из последних
|
||||
MENU_FILE_SAVE=&Сохранить
|
||||
MENU_FILE_EXIT=Вы&ход
|
||||
MENU_EDIT=&Правка
|
||||
MENU_EDIT_COPY=&Копировать
|
||||
MENU_EDIT_PASTE=&Вставить
|
||||
MENU_EDIT_CUT=Вырезать
|
||||
MENU_EDIT_UNDO=&Отмена
|
||||
MENU_EDIT_REDO=&Повторить
|
||||
MENU_EDIT_PREFERENCES=&Настройки
|
||||
MENU_VIEW=&Вид
|
||||
MENU_VIEW_LANGUAGE=&Язык интерфейса
|
||||
MENU_VIEW_LANGUAGE_EN=English
|
||||
MENU_VIEW_LANGUAGE_RU=Русский
|
||||
MENU_VIEW_THEME=&Тема
|
||||
MENU_VIEW_THEME_DEFAULT=Стандартная
|
||||
MENU_VIEW_THEME_CUSTOM1=Пример 1
|
||||
MENU_WINDOW=&Окно
|
||||
MENU_WINDOW_PREFERENCES=&Настройки
|
||||
MENU_HELP=&Справка
|
||||
MENU_HELP_VIEW_HELP=&Просмотр справки
|
||||
MENU_HELP_ABOUT=&О программе
|
||||
|
||||
TAB_LONG_LIST=Длинный список
|
||||
TAB_BUTTONS=Кнопки
|
||||
TAB_ANIMATION=Анимация
|
||||
TAB_TABLE_LAYOUT=Табличный layout
|
||||
TAB_EDITORS=Редакторы
|
||||
|
||||
|
After Width: | Height: | Size: 8.2 KiB |
After Width: | Height: | Size: 956 B |
After Width: | Height: | Size: 605 B |
After Width: | Height: | Size: 593 B |
After Width: | Height: | Size: 701 B |
After Width: | Height: | Size: 635 B |
After Width: | Height: | Size: 771 B |
After Width: | Height: | Size: 559 B |
After Width: | Height: | Size: 436 B |
After Width: | Height: | Size: 368 B |
After Width: | Height: | Size: 598 B |
After Width: | Height: | Size: 753 B |
After Width: | Height: | Size: 810 B |
After Width: | Height: | Size: 8.8 KiB |
13
src/app.d
|
@ -3,6 +3,7 @@ module app;
|
|||
import dlangui.all;
|
||||
import std.stdio;
|
||||
import std.conv;
|
||||
import dlangide.ui.frame;
|
||||
|
||||
|
||||
mixin APP_ENTRY_POINT;
|
||||
|
@ -11,10 +12,10 @@ mixin APP_ENTRY_POINT;
|
|||
extern (C) int UIAppMain(string[] args) {
|
||||
// resource directory search paths
|
||||
string[] resourceDirs = [
|
||||
appendPath(exePath, "../../../res/"), // for Visual D and DUB builds
|
||||
appendPath(exePath, "../../../res/mdpi/"), // for Visual D and DUB builds
|
||||
appendPath(exePath, "../../../../res/"),// for Mono-D builds
|
||||
appendPath(exePath, "../../../../res/mdpi/"),// for Mono-D builds
|
||||
//appendPath(exePath, "../../../res/"), // for Visual D and DUB builds
|
||||
//appendPath(exePath, "../../../res/mdpi/"), // for Visual D and DUB builds
|
||||
//appendPath(exePath, "../../../../res/"),// for Mono-D builds
|
||||
//appendPath(exePath, "../../../../res/mdpi/"),// for Mono-D builds
|
||||
appendPath(exePath, "res/"), // when res dir is located at the same directory as executable
|
||||
appendPath(exePath, "../res/"), // when res dir is located at project directory
|
||||
appendPath(exePath, "../../res/"), // when res dir is located at the same directory as executable
|
||||
|
@ -31,10 +32,10 @@ extern (C) int UIAppMain(string[] args) {
|
|||
Platform.instance.uiTheme = "theme_default";
|
||||
|
||||
// create window
|
||||
Window window = Platform.instance.createWindow("My Window", null);
|
||||
Window window = Platform.instance.createWindow("Dlang IDE", null);
|
||||
|
||||
// create some widget to show in window
|
||||
window.mainWidget = (new Button()).text("Hello world"d).margins(Rect(20,20,20,20));
|
||||
window.mainWidget = new IDEFrame(window);
|
||||
|
||||
// show window
|
||||
window.show();
|
||||
|
|