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 class HomeScreen : ScrollWidget { 15 protected IDEFrame _frame; 16 protected HorizontalLayout _content; 17 protected VerticalLayout _startItems; 18 protected VerticalLayout _recentItems; 19 this(string ID, IDEFrame frame) { 20 super(ID); 21 import dlangide.ui.frame; 22 //styleId = STYLE_EDIT_BOX; 23 _frame = frame; 24 uint linkColor = currentTheme.customColor("link_color", 0x2020FF); 25 _content = new HorizontalLayout("HOME_SCREEN_BODY"); 26 _content.layoutWidth(FILL_PARENT).layoutHeight(FILL_PARENT); 27 VerticalLayout _column1 = new VerticalLayout(); 28 int pad = BACKEND_GUI ? 20 : 1; 29 _column1.layoutWidth(FILL_PARENT).layoutHeight(FILL_PARENT).padding(Rect(pad, pad, pad, pad)); 30 VerticalLayout _column2 = new VerticalLayout(); 31 _column2.layoutWidth(FILL_PARENT).layoutHeight(FILL_PARENT).padding(Rect(pad, pad, pad, pad)); 32 _content.addChild(_column1); 33 _content.addChild(_column2); 34 _column1.addChild((new TextWidget(null, "Dlang IDE "d ~ DLANGIDE_VERSION)).fontSize(32).textColor(linkColor)); 35 _column1.addChild((new TextWidget(null, UIString.fromId("DESCRIPTION"c))).fontSize(20)); 36 _column1.addChild((new TextWidget(null, UIString.fromId("COPYRIGHT"c))).fontSize(22).textColor(linkColor)); 37 _column1.addChild(new VSpacer()); 38 _column1.addChild((new TextWidget(null, UIString.fromId("START_WITH"c))).fontSize(20).textColor(linkColor)); 39 _startItems = new VerticalLayout(); 40 _recentItems = new VerticalLayout(); 41 _startItems.addChild(new ImageTextButton(ACTION_FILE_OPEN_WORKSPACE)); 42 _startItems.addChild(new ImageTextButton(ACTION_FILE_NEW_WORKSPACE)); 43 _startItems.addChild(new ImageTextButton(ACTION_FILE_NEW_PROJECT)); 44 _column1.addChild(_startItems); 45 _column1.addChild(new VSpacer()); 46 47 // Recent workspaces 48 _column1.addChild((new TextWidget(null, UIString.fromId("RECENT"c))).fontSize(20).textColor(linkColor)); 49 string[] recentWorkspaces = _frame.settings.recentWorkspaces; 50 if (recentWorkspaces.length) { 51 foreach(fn; recentWorkspaces) { 52 Action a = ACTION_FILE_OPEN_WORKSPACE.clone(); 53 a.label = UIString.fromRaw(toUTF32(stripExtension(baseName(fn)))); 54 a.stringParam = fn; 55 _column1.addChild(new LinkButton(a)); 56 } 57 } else { 58 _recentItems.addChild((new TextWidget(null, UIString.fromId("NO_RECENT"c)))); 59 } 60 _column1.addChild(_recentItems); 61 62 // Useful links 63 _column1.addChild(new VSpacer()); 64 _column2.addChild((new TextWidget(null, UIString.fromId("USEFUL_LINKS"c))).fontSize(20).textColor(linkColor)); 65 _column2.addChild(new UrlImageTextButton(null, UIString.fromId("D_LANG"c).value, "http://dlang.org/")); 66 _column2.addChild(new UrlImageTextButton(null, UIString.fromId("DUB_REP"c).value, "http://code.dlang.org/")); 67 _column2.addChild(new UrlImageTextButton(null, UIString.fromId("DLANG_UI"c).value, "https://github.com/buggins/dlangui")); 68 _column2.addChild(new UrlImageTextButton(null, UIString.fromId("DLANG_IDE"c).value, "https://github.com/buggins/dlangide")); 69 _column2.addChild(new VSpacer()); 70 contentWidget = _content; 71 } 72 }