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 import dlangui.core.i18n;
10
11 import std.path;
12 import std.utf : toUTF32;
13
14 immutable string HELP_PAGE_URL = "https://github.com/buggins/dlangide/wiki";
15 immutable string HELP_DONATION_URL = "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=H2ADZV8S6TDHQ";
16
17
18 class HomeScreen : ScrollWidget {
19 protected IDEFrame _frame;
20 protected HorizontalLayout _content;
21 protected VerticalLayout _startItems;
22 protected VerticalLayout _recentItems;
23 this(string ID, IDEFrame frame) {
24 super(ID);
25 import dlangide.ui.frame;
26 //styleId = STYLE_EDIT_BOX;
27 _frame = frame;
28 _content = new HorizontalLayout("HOME_SCREEN_BODY");
29 _content.layoutWidth(FILL_PARENT).layoutHeight(FILL_PARENT);
30 VerticalLayout _column1 = new VerticalLayout();
31 int pad = BACKEND_GUI ? 20 : 1;
32 _column1.layoutWidth(FILL_PARENT).layoutHeight(FILL_PARENT).padding(Rect(pad, pad, pad, pad));
33 VerticalLayout _column2 = new VerticalLayout();
34 _column2.layoutWidth(FILL_PARENT).layoutHeight(FILL_PARENT).padding(Rect(pad, pad, pad, pad));
35 _content.addChild(_column1);
36 _content.addChild(_column2);
37 _column1.addChild((new TextWidget(null, "Dlang IDE "d ~ DLANGIDE_VERSION)).styleId("HOME_SCREEN_TITLE"));
38 _column1.addChild((new TextWidget(null, UIString.fromId("DESCRIPTION"c))).styleId("HOME_SCREEN_TITLE2"));
39 _column1.addChild((new TextWidget(null, UIString.fromId("COPYRIGHT"c))).styleId("HOME_SCREEN_TITLE2"));
40 _column1.addChild(new VSpacer());
41 _column1.addChild((new TextWidget(null, UIString.fromId("START_WITH"c))).styleId("HOME_SCREEN_TITLE"));
42 _startItems = new VerticalLayout();
43 _recentItems = new VerticalLayout();
44 _startItems.addChild(new ImageTextButton(ACTION_FILE_OPEN_WORKSPACE));
45 _startItems.addChild(new ImageTextButton(ACTION_FILE_NEW_WORKSPACE));
46 _startItems.addChild(new ImageTextButton(ACTION_FILE_NEW_PROJECT));
47 _column1.addChild(_startItems);
48 _column1.addChild(new VSpacer());
49
50 // Recent workspaces
51 _column1.addChild((new TextWidget(null, UIString.fromId("RECENT"c))).styleId("HOME_SCREEN_TITLE"));
52 string[] recentWorkspaces = _frame.settings.recentWorkspaces;
53 if (recentWorkspaces.length) {
54 foreach(fn; recentWorkspaces) {
55 Action a = ACTION_FILE_OPEN_WORKSPACE.clone();
56 a.label = UIString.fromRaw(toUTF32(stripExtension(baseName(fn))));
57 a.stringParam = fn;
58 _column1.addChild(new LinkButton(a));
59 }
60 } else {
61 _recentItems.addChild((new TextWidget(null, UIString.fromId("NO_RECENT"c))));
62 }
63 _column1.addChild(_recentItems);
64
65 // Useful links
66 _column1.addChild(new VSpacer());
67 _column2.addChild((new TextWidget(null, UIString.fromId("USEFUL_LINKS"c))).styleId("HOME_SCREEN_TITLE"));
68 _column2.addChild(new UrlImageTextButton(null, UIString.fromId("D_LANG"c).value, "http://dlang.org/"));
69 _column2.addChild(new UrlImageTextButton(null, UIString.fromId("DLANG_DOWNLOADS"c).value, "https://dlang.org/download.html"));
70 _column2.addChild(new UrlImageTextButton(null, UIString.fromId("DUB_REP"c).value, "http://code.dlang.org/"));
71 _column2.addChild(new UrlImageTextButton(null, UIString.fromId("DLANG_UI"c).value, "https://github.com/buggins/dlangui"));
72 _column2.addChild(new UrlImageTextButton(null, UIString.fromId("DLANG_IDE"c).value, "https://github.com/buggins/dlangide"));
73 _column2.addChild(new UrlImageTextButton(null, UIString.fromId("DLANG_IDE_HELP"c).value, HELP_PAGE_URL));
74 _column2.addChild(new UrlImageTextButton(null, UIString.fromId("DLANG_TOUR"c).value, "https://tour.dlang.org/"));
75 _column2.addChild(new UrlImageTextButton(null, UIString.fromId("DLANG_VIBED"c).value, "http://vibed.org/"));
76 _column2.addChild(new UrlImageTextButton(null, UIString.fromId("DLANG_FORUM"c).value, "http://forum.dlang.org/"));
77 _column1.addChild(new VSpacer());
78 _column2.addChild((new TextWidget(null, UIString.fromId("DLANG_IDE_DONATE"c))).styleId("HOME_SCREEN_TITLE"));
79 _column2.addChild(new UrlImageTextButton(null, UIString.fromId("DLANG_IDE_DONATE_PAYPAL"c).value, HELP_DONATION_URL));
80
81 _column2.addChild(new VSpacer());
82 contentWidget = _content;
83 }
84 }