X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=rcp%2Forg.argeo.minidesktop%2Fsrc%2Forg%2Fargeo%2Fminidesktop%2FMiniDesktopManager.java;h=4d7c03c62c0dc614ca14539ba5c83d28b3a6e53b;hb=e87681b3f907690a2aeefd4b88de058caed7fdc4;hp=a1f6d333e2e33c0de3b6820fdf044b147a3dbb45;hpb=637bb618df290885daac173b5ce0c6a33667bb99;p=gpl%2Fargeo-slc.git diff --git a/rcp/org.argeo.minidesktop/src/org/argeo/minidesktop/MiniDesktopManager.java b/rcp/org.argeo.minidesktop/src/org/argeo/minidesktop/MiniDesktopManager.java index a1f6d333e..4d7c03c62 100644 --- a/rcp/org.argeo.minidesktop/src/org/argeo/minidesktop/MiniDesktopManager.java +++ b/rcp/org.argeo.minidesktop/src/org/argeo/minidesktop/MiniDesktopManager.java @@ -11,6 +11,7 @@ import org.eclipse.swt.custom.CTabFolder; import org.eclipse.swt.custom.CTabItem; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.ImageData; import org.eclipse.swt.graphics.Point; @@ -37,28 +38,40 @@ public class MiniDesktopManager { private final boolean fullscreen; private final boolean stacking; + private MiniDesktopImages images; + public MiniDesktopManager(boolean fullscreen, boolean stacking) { this.fullscreen = fullscreen; this.stacking = stacking; } public void init() { + Display.setAppName("Mini SWT Desktop"); display = Display.getCurrent(); if (display != null) throw new IllegalStateException("Already a display " + display); display = new Display(); + if (display.getTouchEnabled()) { + System.out.println("Touch enabled."); + } + + images = new MiniDesktopImages(display); + int toolBarSize = 48; if (isFullscreen()) { rootShell = new Shell(display, SWT.NO_TRIM); rootShell.setFullScreen(true); Rectangle bounds = display.getBounds(); + rootShell.setLocation(0, 0); rootShell.setSize(bounds.width, bounds.height); } else { - rootShell = new Shell(display, SWT.SHELL_TRIM); + rootShell = new Shell(display, SWT.CLOSE | SWT.RESIZE); Rectangle shellArea = rootShell.computeTrim(200, 200, 800, 480); rootShell.setSize(shellArea.width, shellArea.height); + rootShell.setText(Display.getAppName()); + rootShell.setImage(images.terminalIcon); } rootShell.setLayout(noSpaceGridLayout(new GridLayout(2, false))); @@ -75,17 +88,24 @@ public class MiniDesktopManager { } else { toolBar = new ToolBar(toolBarArea, SWT.VERTICAL | SWT.FLAT | SWT.BORDER); createDock(toolBar); - toolBarArea.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false)); + toolBarArea.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); } if (isStacking()) { - tabFolder = new CTabFolder(rootShell, SWT.MULTI); + tabFolder = new CTabFolder(rootShell, SWT.MULTI | SWT.BORDER | SWT.BOTTOM); + tabFolder.setLayout(noSpaceGridLayout(new GridLayout())); tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + + Color selectionBackground = display.getSystemColor(SWT.COLOR_LIST_SELECTION); + tabFolder.setSelectionBackground(selectionBackground); + // background Control background = createBackground(tabFolder); - CTabItem noCloseItem = new CTabItem(tabFolder, SWT.NONE); - noCloseItem.setText("Home"); - noCloseItem.setControl(background); + CTabItem homeTabItem = new CTabItem(tabFolder, SWT.NONE); + homeTabItem.setText("Home"); + homeTabItem.setImage(images.homeIcon); + homeTabItem.setControl(background); + tabFolder.setFocus(); } else { createBackground(rootShell); } @@ -94,16 +114,17 @@ public class MiniDesktopManager { // rootShell.layout(true, true); if (toolBarShell != null) { - toolBarShell.setLocation(new Point(0, 0)); + int toolBarShellY = (display.getBounds().height - toolBar.getSize().y) / 2; + toolBarShell.setLocation(0, toolBarShellY); toolBarShell.open(); } } protected void createDock(ToolBar toolBar) { // Terminal - addToolItem(toolBar, display.getSystemImage(SWT.ICON_INFORMATION), "Terminal", () -> { + addToolItem(toolBar, images.terminalIcon, "Terminal", () -> { String url = System.getProperty("user.home"); - AppContext appContext = createAppParent(); + AppContext appContext = createAppParent(images.terminalIcon); new MiniTerminal(appContext.getAppParent(), url) { @Override @@ -130,9 +151,9 @@ public class MiniDesktopManager { }); // Web browser - addToolItem(toolBar, display.getSystemImage(SWT.ICON_QUESTION), "Browser", () -> { - String url = "https://duckduckgo.com/"; - AppContext appContext = createAppParent(); + addToolItem(toolBar, images.browserIcon, "Browser", () -> { + String url = "https://start.duckduckgo.com/"; + AppContext appContext = createAppParent(images.browserIcon); new MiniBrowser(appContext.getAppParent(), url, false, false) { @Override protected void titleChanged(String title) { @@ -148,9 +169,9 @@ public class MiniDesktopManager { }); // File explorer - addToolItem(toolBar, display.getSystemImage(SWT.ICON_WARNING), "Explorer", () -> { + addToolItem(toolBar, images.explorerIcon, "Explorer", () -> { String url = System.getProperty("user.home"); - AppContext appContext = createAppParent(); + AppContext appContext = createAppParent(images.explorerIcon); new MiniExplorer(appContext.getAppParent(), url) { @Override @@ -166,8 +187,11 @@ public class MiniDesktopManager { openApp(appContext); }); + // Separator + new ToolItem(toolBar, SWT.SEPARATOR); + // Exit - addToolItem(toolBar, display.getSystemImage(SWT.ICON_ERROR), "Exit", () -> rootShell.dispose()); + addToolItem(toolBar, images.exitIcon, "Exit", () -> rootShell.dispose()); toolBar.pack(); } @@ -190,15 +214,18 @@ public class MiniDesktopManager { }); } - protected AppContext createAppParent() { + protected AppContext createAppParent(Image icon) { if (isStacking()) { - Composite appParent = new Composite(tabFolder, SWT.NONE); + Composite appParent = new Composite(tabFolder, SWT.CLOSE); appParent.setLayout(noSpaceGridLayout(new GridLayout())); CTabItem item = new CTabItem(tabFolder, SWT.CLOSE); + item.setImage(icon); item.setControl(appParent); return new AppContext(item); } else { - Shell shell = new Shell(rootShell, SWT.SHELL_TRIM); + Shell shell = isFullscreen() ? new Shell(rootShell, SWT.SHELL_TRIM) + : new Shell(rootShell.getDisplay(), SWT.SHELL_TRIM); + shell.setImage(icon); return new AppContext(shell); } } @@ -210,6 +237,7 @@ public class MiniDesktopManager { shell.setSize(new Point(800, 480)); } if (appContext.tabItem != null) { + tabFolder.setFocus(); tabFolder.setSelection(appContext.tabItem); } } @@ -222,6 +250,14 @@ public class MiniDesktopManager { } protected void initBackground(Composite backgroundArea) { + MiniHomePart homePart = new MiniHomePart() { + + @Override + protected void fillAppsToolBar(ToolBar toolBar) { + createDock(toolBar); + } + }; + homePart.createUiPart(backgroundArea, null); } public void run() {