1 module dlangide.ui.homescreen;
2 
3 import dlangui.widgets.layouts;
4 import dlangui.widgets.widget;
5 import dlangui.widgets.scroll;
6 import dlangui.widgets.controls;
7 import dlangide.ui.frame;
8 import dlangide.ui.commands;
9 
10 import std.path;
11 import std.utf : toUTF32;
12 
13 class HomeScreen : ScrollWidget {
14     protected IDEFrame _frame;
15     protected HorizontalLayout _content;
16     protected VerticalLayout _startItems;
17     protected VerticalLayout _recentItems;
18     this(string ID, IDEFrame frame) {
19         super(ID);
20         import dlangide.ui.frame;
21         //styleId = STYLE_EDIT_BOX;
22         _frame = frame;
23         uint linkColor = currentTheme.customColor("link_color", 0x2020FF);
24         _content = new HorizontalLayout("HOME_SCREEN_BODY");
25         _content.layoutWidth(FILL_PARENT).layoutHeight(FILL_PARENT);
26         VerticalLayout _column1 = new VerticalLayout();
27         int pad = BACKEND_GUI ? 20 : 1;
28         _column1.layoutWidth(FILL_PARENT).layoutHeight(FILL_PARENT).padding(Rect(pad, pad, pad, pad));
29         VerticalLayout _column2 = new VerticalLayout();
30         _column2.layoutWidth(FILL_PARENT).layoutHeight(FILL_PARENT).padding(Rect(pad, pad, pad, pad));
31         _content.addChild(_column1);
32         _content.addChild(_column2);
33         _column1.addChild((new TextWidget(null, "Dlang IDE"d ~ " " ~ DLANGIDE_VERSION)).fontSize(32).textColor(linkColor));
34         _column1.addChild((new TextWidget(null, "D language IDE written in D"d)).fontSize(20));
35         _column1.addChild((new TextWidget(null, "(c) Vadim Lopatin 2015"d)).fontSize(22).textColor(linkColor));
36         _column1.addChild(new VSpacer());
37         _column1.addChild((new TextWidget(null, "Start with:"d)).fontSize(20).textColor(linkColor));
38         _startItems = new VerticalLayout();
39         _recentItems = new VerticalLayout();
40         _startItems.addChild(new ImageTextButton(ACTION_FILE_OPEN_WORKSPACE));
41         _startItems.addChild(new ImageTextButton(ACTION_FILE_NEW_WORKSPACE));
42         _startItems.addChild(new ImageTextButton(ACTION_FILE_NEW_PROJECT));
43         _column1.addChild(_startItems);
44         _column1.addChild(new VSpacer());
45         _column1.addChild((new TextWidget(null, "Recent:"d)).fontSize(20).textColor(linkColor));
46         string[] recentWorkspaces = _frame.settings.recentWorkspaces;
47         if (recentWorkspaces.length) {
48             foreach(fn; recentWorkspaces) {
49                 Action a = ACTION_FILE_OPEN_WORKSPACE.clone();
50                 a.label = UIString(toUTF32(stripExtension(baseName(fn))));
51                 a.stringParam = fn;
52                 _column1.addChild(new LinkButton(a));
53             }
54         } else {
55             _recentItems.addChild((new TextWidget(null, "No recent items"d)));
56         }
57         _column1.addChild(_recentItems);
58         _column1.addChild(new VSpacer());
59         _column2.addChild((new TextWidget(null, "Useful Links:"d)).fontSize(20).textColor(linkColor));
60         _column2.addChild(new UrlImageTextButton(null, "D Programming Language"d, "http://dlang.org/"));
61         _column2.addChild(new UrlImageTextButton(null, "DUB repository"d, "http://code.dlang.org/"));
62         _column2.addChild(new UrlImageTextButton(null, "DLangUI on GitHub"d, "https://github.com/buggins/dlangui"));
63         _column2.addChild(new UrlImageTextButton(null, "DLangIDE on GitHub"d, "https://github.com/buggins/dlangide"));
64         _column2.addChild(new VSpacer());
65         contentWidget = _content;
66     }
67 }