Home Screen, part 1

This commit is contained in:
Vadim Lopatin 2015-01-27 12:18:06 +03:00
parent 75a2bf89a7
commit 01ffc1dffa
6 changed files with 68 additions and 2 deletions

View File

@ -203,6 +203,7 @@
<File path="src\dlangide\ui\commands.d" />
<File path="src\dlangide\ui\dsourceedit.d" />
<File path="src\dlangide\ui\frame.d" />
<File path="src\dlangide\ui\homescreen.d" />
<File path="src\dlangide\ui\outputpanel.d" />
<File path="src\dlangide\ui\wspanel.d" />
</Folder>

View File

@ -36,6 +36,8 @@ extern (C) int UIAppMain(string[] args) {
// create some widget to show in window
window.windowIcon = drawableCache.getImage("dlangui-logo1");
// open home screen tab
frame.showHomeScreen();
// for testing: load workspace at startup
frame.loadWorkspace(appendPath(exePath, "../workspaces/sample1/sample1.dlangidews"));

View File

@ -7,6 +7,8 @@ enum IDEActions : int {
None = 0,
//ProjectOpen = 1010000,
FileNew = 1010000,
FileNewWorkspace,
FileNewProject,
FileOpen,
FileOpenWorkspace,
FileSave,
@ -30,7 +32,9 @@ enum IDEActions : int {
HelpAbout,
}
const Action ACTION_FILE_NEW = new Action(IDEActions.FileOpen, "MENU_FILE_NEW"c, "document-new", KeyCode.KEY_N, KeyFlag.Control);
const Action ACTION_FILE_NEW_SOURCE_FILE = new Action(IDEActions.FileNew, "MENU_FILE_NEW_SOURCE_FILE"c, "document-new", KeyCode.KEY_N, KeyFlag.Control);
const Action ACTION_FILE_NEW_PROJECT = new Action(IDEActions.FileNewProject, "MENU_FILE_NEW_PROJECT"c);
const Action ACTION_FILE_NEW_WORKSPACE = new Action(IDEActions.FileNewWorkspace, "MENU_FILE_NEW_WORKSPACE"c);
const Action ACTION_FILE_OPEN = new Action(IDEActions.FileOpen, "MENU_FILE_OPEN"c, "document-open", KeyCode.KEY_O, KeyFlag.Control);
const Action ACTION_FILE_OPEN_WORKSPACE = new Action(IDEActions.FileOpenWorkspace, "MENU_FILE_OPEN_WORKSPACE"c, null, KeyCode.KEY_O, KeyFlag.Control | KeyFlag.Shift);
const Action ACTION_FILE_SAVE = new Action(IDEActions.FileSave, "MENU_FILE_SAVE"c, "document-save", KeyCode.KEY_S, KeyFlag.Control);

View File

@ -18,6 +18,7 @@ import dlangide.ui.commands;
import dlangide.ui.wspanel;
import dlangide.ui.outputpanel;
import dlangide.ui.dsourceedit;
import dlangide.ui.homescreen;
import dlangide.workspace.workspace;
import dlangide.workspace.project;
@ -109,6 +110,18 @@ class IDEFrame : AppFrame {
return true;
}
static immutable HOME_SCREEN_ID = "HOME_SCREEN";
void showHomeScreen() {
int index = _tabs.tabIndex(HOME_SCREEN_ID);
if (index >= 0) {
_tabs.selectTab(index, true);
} else {
HomeScreen home = new HomeScreen(HOME_SCREEN_ID, this);
_tabs.addTab(home, "Home"d);
_tabs.selectTab(HOME_SCREEN_ID, true);
}
}
void onTabChanged(string newActiveTabId, string previousTabId) {
int index = _tabs.tabIndex(newActiveTabId);
if (index >= 0) {
@ -192,7 +205,10 @@ class IDEFrame : AppFrame {
mainMenuItems = new MenuItem();
MenuItem fileItem = new MenuItem(new Action(1, "MENU_FILE"));
fileItem.add(ACTION_FILE_NEW, ACTION_FILE_OPEN_WORKSPACE, ACTION_FILE_OPEN,
MenuItem fileNewItem = new MenuItem(new Action(1, "MENU_FILE_NEW"));
fileNewItem.add(ACTION_FILE_NEW_SOURCE_FILE, ACTION_FILE_NEW_WORKSPACE, ACTION_FILE_NEW_PROJECT);
fileItem.add(fileNewItem);
fileItem.add(ACTION_FILE_OPEN_WORKSPACE, ACTION_FILE_OPEN,
ACTION_FILE_SAVE, ACTION_FILE_SAVE_AS, ACTION_FILE_SAVE_ALL, ACTION_FILE_EXIT);
MenuItem editItem = new MenuItem(new Action(2, "MENU_EDIT"));

View File

@ -0,0 +1,40 @@
module dlangide.ui.homescreen;
import dlangui.widgets.layouts;
import dlangui.widgets.widget;
import dlangui.widgets.scroll;
import dlangui.widgets.controls;
import dlangide.ui.frame;
import dlangide.ui.commands;
class HomeScreen : ScrollWidget {
protected IDEFrame _frame;
protected HorizontalLayout _content;
this(string ID, IDEFrame frame) {
super(ID);
backgroundColor = 0xFFFFFF;
_frame = frame;
_content = new HorizontalLayout("HOME_SCREEN_BODY");
_content.layoutWidth(FILL_PARENT).layoutHeight(FILL_PARENT);
VerticalLayout _column1 = new VerticalLayout();
_column1.layoutWidth(FILL_PARENT).layoutHeight(FILL_PARENT).padding(Rect(20, 20, 20, 20));
VerticalLayout _column2 = new VerticalLayout();
_column2.layoutWidth(FILL_PARENT).layoutHeight(FILL_PARENT).padding(Rect(20, 20, 20, 20));
_content.addChild(_column1);
_content.addChild(_column2);
_column1.addChild((new TextWidget(null, "Dlang IDE"d)).fontSize(32).textColor(0x000080));
_column1.addChild((new TextWidget(null, "D language IDE written in D"d)).fontSize(24));
_column1.addChild((new TextWidget(null, "(c) Vadim Lopatin 2015"d)).fontSize(24).textColor(0x000080));
_column1.addChild(new VSpacer());
_column1.addChild(new TextWidget(null, "Start:"d));
_column1.addChild(new ImageTextButton(ACTION_FILE_NEW_WORKSPACE));
_column1.addChild(new ImageTextButton(ACTION_FILE_NEW_PROJECT));
_column1.addChild(new ImageTextButton(ACTION_FILE_OPEN_WORKSPACE));
_column1.addChild(new VSpacer());
_column1.addChild(new TextWidget(null, "Recent:"d));
_column1.addChild(new VSpacer());
_column2.addChild(new TextWidget(null, "Useful links:"d));
_column2.addChild(new VSpacer());
contentWidget = _content;
}
}

View File

@ -1,6 +1,9 @@
EXIT=Exit
MENU_FILE=&FILE
MENU_FILE_NEW=&New
MENU_FILE_NEW_SOURCE_FILE=New source file
MENU_FILE_NEW_PROJECT=New project
MENU_FILE_NEW_WORKSPACE=New workspace
MENU_FILE_OPEN=&Open file
MENU_FILE_OPEN_WORKSPACE=Open project or workspace
MENU_FILE_OPEN_RECENT=Open recent