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 uint linkColor = currentTheme.customColor("link_color", 0x2020FF); 29 _content = new HorizontalLayout("HOME_SCREEN_BODY"); 30 _content.layoutWidth(FILL_PARENT).layoutHeight(FILL_PARENT); 31 VerticalLayout _column1 = new VerticalLayout(); 32 int pad = BACKEND_GUI ? 20 : 1; 33 _column1.layoutWidth(FILL_PARENT).layoutHeight(FILL_PARENT).padding(Rect(pad, pad, pad, pad)); 34 VerticalLayout _column2 = new VerticalLayout(); 35 _column2.layoutWidth(FILL_PARENT).layoutHeight(FILL_PARENT).padding(Rect(pad, pad, pad, pad)); 36 _content.addChild(_column1); 37 _content.addChild(_column2); 38 _column1.addChild((new TextWidget(null, "Dlang IDE "d ~ DLANGIDE_VERSION)).fontSize(32).textColor(linkColor)); 39 _column1.addChild((new TextWidget(null, UIString.fromId("DESCRIPTION"c))).fontSize(20)); 40 _column1.addChild((new TextWidget(null, UIString.fromId("COPYRIGHT"c))).fontSize(22).textColor(linkColor)); 41 _column1.addChild(new VSpacer()); 42 _column1.addChild((new TextWidget(null, UIString.fromId("START_WITH"c))).fontSize(20).textColor(linkColor)); 43 _startItems = new VerticalLayout(); 44 _recentItems = new VerticalLayout(); 45 _startItems.addChild(new ImageTextButton(ACTION_FILE_OPEN_WORKSPACE)); 46 _startItems.addChild(new ImageTextButton(ACTION_FILE_NEW_WORKSPACE)); 47 _startItems.addChild(new ImageTextButton(ACTION_FILE_NEW_PROJECT)); 48 _column1.addChild(_startItems); 49 _column1.addChild(new VSpacer()); 50 51 // Recent workspaces 52 _column1.addChild((new TextWidget(null, UIString.fromId("RECENT"c))).fontSize(20).textColor(linkColor)); 53 string[] recentWorkspaces = _frame.settings.recentWorkspaces; 54 if (recentWorkspaces.length) { 55 foreach(fn; recentWorkspaces) { 56 Action a = ACTION_FILE_OPEN_WORKSPACE.clone(); 57 a.label = UIString.fromRaw(toUTF32(stripExtension(baseName(fn)))); 58 a.stringParam = fn; 59 _column1.addChild(new LinkButton(a)); 60 } 61 } else { 62 _recentItems.addChild((new TextWidget(null, UIString.fromId("NO_RECENT"c)))); 63 } 64 _column1.addChild(_recentItems); 65 66 // Useful links 67 _column1.addChild(new VSpacer()); 68 _column2.addChild((new TextWidget(null, UIString.fromId("USEFUL_LINKS"c))).fontSize(20).textColor(linkColor)); 69 _column2.addChild(new UrlImageTextButton(null, UIString.fromId("D_LANG"c).value, "http://dlang.org/")); 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))).fontSize(20).textColor(linkColor)); 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 }